批量修改mysql所有库所有表的字段类型

批量修改mysql所有库所有表的字段类型

  1. 生成语句
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;
  1. 复制语句执行
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 "逻辑删除标识"; 
……

在这里插入图片描述

你可能感兴趣的:(mysql,android,数据库)