码迷,mamicode.com
首页 > 其他好文 > 详细

批量修改表注释

时间:2019-05-25 19:43:20      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:html   sele   环境   注释   mtu   CMF   cifs   bin   bit   

一:业务应用场景

1.测试环境执行重新建表,导致表注释乱码

2.数据已导入,数据中不存在中文字符

 

二:批量修改表注释乱码语句

select concat("ALTER TABLE ","`",col.TABLE_NAME,"`"," CHANGE ","`",col.COLUMN_NAME,"`"," ","`",col.COLUMN_NAME,"`"," ",col.COLUMN_TYPE , " ", if(col.CHARACTER_SET_NAME is null," ",concat(" character set ",col.CHARACTER_SET_NAME," ")), if(col.COLLATION_NAME is null," ",concat(" COLLATE ","‘",col.COLLATION_NAME,"‘ ")), if(col.IS_NULLABLE=‘NO‘," NOT NULL "," null "), if(col.COLUMN_DEFAULT is null , if(col.EXTRA=‘auto_increment‘ or col.IS_NULLABLE=‘NO‘," "," DEFAULT null ") ,concat(" DEFAULT ",if(col.DATA_TYPE=‘timestamp‘ or col.DATA_TYPE=‘bit‘ ,col.COLUMN_DEFAULT,concat("‘",col.COLUMN_DEFAULT,"‘")))), if(col.EXTRA is null ," ",concat(" ",col.EXTRA," " )), " COMMENT "," ","‘",col.COLUMN_COMMENT,"‘",";") change_column_type from information_schema.COLUMNS col join information_schema.tables tbl on col.TABLE_SCHEMA=tbl.TABLE_SCHEMA and col.TABLE_NAME=tbl.TABLE_NAME where col.TABLE_SCHEMA=‘ems‘ and tbl.TABLE_TYPE=‘BASE TABLE‘ and col.table_name=‘t0‘

 

原文地址:

https://www.cnblogs.com/zejin2008/p/5133858.html

批量修改表注释

标签:html   sele   环境   注释   mtu   CMF   cifs   bin   bit   

原文地址:https://www.cnblogs.com/zhs0/p/10923424.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!