1.查詢確認要修改的字段
select
table_name, column_name, column_comment
from
information_schema.columns
where
table_schema = '你的數據庫名稱'
and column_comment like '%需要替換的字符串%';
2.生成批量修改語句
select
concat( 'alter table `', table_name, '` modify column `', column_name, '` ',
' comment ''', replace ( column_comment, '舊字符串', '需要替換的字符串' ), ''';' ) as alter_sql
from
information_schema.columns
where
table_schema = '你的數據庫名稱'
and column_comment like '%需要替換的字符串%';
3.執行生成的SQL語句
將上一步生成的所有alter語句複製出來,一次性執行即可完成批量替換。