Horje
add column to all tables after first column mysql Code Example
mysql alter table add column first
-- ALTER TABLE tbl_name ADD COLUMN column_name column_definition 
--		[FIRST|AFTER existing_column];
ALTER TABLE office ADD COLUMN phone VARCHAR(200) DEFAULT '000' AFTER name;
ALTER TABLE office ADD COLUMN flag INT(1) FIRST;
ALTER TABLE office ADD COLUMN last_col INT(2);	-- Last column is default position
-- ↓ Test it (Fiddle)
add column to all tables after first column mysql
SELECT CONCAT('ALTER TABLE ', table_schema,'.', TABLE_NAME,' ADD COLUMN `hash` VARCHAR(50) NULL DEFAULT UUID() AFTER ', first_column, ';') AS ddl

FROM (

	SELECT
		(
			SELECT `COLUMN_NAME`
			FROM `INFORMATION_SCHEMA`.`COLUMNS`
			WHERE `TABLE_SCHEMA`=t.TABLE_SCHEMA AND `TABLE_NAME`=t.TABLE_NAME
			LIMIT 1
		) AS 'first_column',
		t.*
	FROM
	information_schema.tables t
	WHERE table_schema = 'your_table_name' AND table_type = 'base table'
	
) AS x;




Sql

Related
select * from mysql.proc Code Example select * from mysql.proc Code Example
in sql developer where equal queres Code Example in sql developer where equal queres Code Example
sql distinct only one column Code Example sql distinct only one column Code Example
What is the library that should import to use all functional database features in SQLite? Code Example What is the library that should import to use all functional database features in SQLite? Code Example
postgresql gset Code Example postgresql gset Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7