Mysql batch modify table fields to uppercase

Original address: https://blog.csdn.net/csd_nuser/article/details/110038516

The goal of this blog is to integrate most commonly used software installation and usage instructions, and technical solutions release. Please continue to pay attention.

Mysql batch modify table fields to uppercase

One, query all tables

SELECT 

CONCAT('ALTER table ',sc2.table_schema,'.',sc2.table_name,' CHANGE ',' \`',sc2.column_name,'\` \`',UPPER(sc2.column_name),'\` ',  
sc2.column_type,

' ',

CASE WHEN

sc2.is_nullable='NO'

THEN 'not null'

ELSE 'null' END,' COMMENT ''',sc2.column_comment,''';') AS c  
FROM information_schema.tables sc, information_schema.columns sc2
 WHERE sc.table_schema = '你的数据库名'  
   AND sc.table_type = 'base table'  
   AND sc.table_schema = sc2.table_schema  

   AND sc.table_name = sc2.table_name  

Then execute the query results

Guess you like

Origin blog.csdn.net/csd_nuser/article/details/110038516