SELECT CONCAT('alter table ',dt.TABLE_SCHEMA,'.',dc.table,' modify ',dc.columns, ' ', dt.`COLUMN_TYPE`, IF(dt.CHARACTER_SET_NAME IS NULL," ",CONCAT(" character set ",dt.CHARACTER_SET_NAME," ")), IF(dt.COLLATION_NAME IS NULL," ",CONCAT(" COLLATE ","'",dt.COLLATION_NAME,"' ")), IF(dt.IS_NULLABLE='NO'," NOT NULL "," null "), IF(dt.COLUMN_DEFAULT IS NULL , IF(dt.EXTRA='auto_increment' OR dt.IS_NULLABLE='NO'," "," DEFAULT null ") ,CONCAT(" DEFAULT ",IF(dt.DATA_TYPE='timestamp' OR dt.DATA_TYPE='bit' ,dt.COLUMN_DEFAULT,CONCAT("'",dt.COLUMN_DEFAULT,"'")))), IF(dt.EXTRA IS NULL ," ",CONCAT(" ",dt.EXTRA," " )) ,' comment \'',dc.`comment`,'\'',';') FROM supplement_clumn_comment dc LEFT JOIN information_schema.columns dt ON (dc.columns)=(dt.column_name) AND (dc.table)=(dt.TABLE_NAME) AND dt.TABLE_SCHEMA='TELECOM'
supplement_clumn_comment 表结构标签:comment,批量,DEFAULT,dc,mysql,dt,NULL,CONCAT,备注 From: https://www.cnblogs.com/luckyfruit/p/16832232.html
CREATE TABLE `supplement_clumn_comment` (
`table` varchar(200) DEFAULT NULL COMMENT '表名',
`columns` varchar(200) DEFAULT NULL COMMENT '列名',
`comment` varchar(3000) DEFAULT NULL COMMENT '注释'
) ENGINE=InnoDB DEFAULT CHARSET=utf8