批量修改mysql所有库所有表的字段类型
- 生成语句
SELECT
CONCAT('ALTER TABLE `', table_schema, '`.`', table_name, '` MODIFY COLUMN `del_flag` BIGINT default 0 comment "逻辑删除标识"; ') AS sql_statement
FROM
information_schema.columns
where
table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
AND column_name = 'del_flag'
AND table_schema <> 'ifssc-tool'
ORDER BY table_schema;
- 复制语句执行
ALTER TABLE `ifssc-cus`.`sys_d***` MODIFY COLUMN `del_flag` BIGINT default 0 comment "逻辑删除标识";
ALTER TABLE `ifssc-cus`.`sys_re***` MODIFY COLUMN `del_flag` BIGINT default 0 comment "逻辑删除标识";
ALTER TABLE `ifssc-cus`.`sys_re***` MODIFY COLUMN `del_flag` BIGINT default 0 comment "逻辑删除标识";
……