1-- ALTER TABLE tbl_name ADD COLUMN column_name column_definition
2-- [FIRST|AFTER existing_column];
3ALTER TABLE office ADD COLUMN phone VARCHAR(200) DEFAULT '000' AFTER name;
4ALTER TABLE office ADD COLUMN flag INT(1) FIRST;
5ALTER TABLE office ADD COLUMN last_col INT(2); -- Last column is default position
6-- ↓ Test it (Fiddle)
1SELECT count(*) INTO @EXIST
2FROM INFORMATION_SCHEMA.COLUMNS
3WHERE TABLE_SCHEMA = 'mydatabase'
4 AND COLUMN_NAME = 'mycolumn'
5 AND TABLE_NAME = 'mytable' LIMIT 1;
6
7SET @query = IF (@exist <= 0, 'ALTER TABLE mydatabase.`mytable` ADD COLUMN `mycolumn` MEDIUMTEXT NULL',
8 'select \' COLUMN EXISTS\' status');
9PREPARE stmt FROM @query;
10EXECUTE stmt;