批量更新表注释 mysql

-- 生成更新语句

SELECT
CONCAT(
'ALTER TABLE ',
T2.table_name,
' COMMENT ''',
T1.TABLE_COMMENT,
''';'
) sqls
FROM
information_schema.tables T1 LEFT JOIN information_schema.tables T2
ON T1.table_name = T2. table_name AND T1.table_schema='原库名' AND T2.table_schema='新库名'
WHERE T1.table_schema='原库名' AND T2.table_schema='新库名' AND T2.TABLE_COMMENT='';

-- 检查

 

 SELECT table_schema,table_name  ,TABLE_COMMENT '表注释' FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '库名'  ; 

你可能感兴趣的:(批量更新表注释 mysql)