/*dynamically change the column name of a table to lowercase*/SelectConcat_ws ("','ALTER TABLE', A.table_name,'Modify',Lower(A.column_name),' ', A.column_type, Case whenA.is_nullable= 'NO' Then 'Not null' Else NULL End, Case whenA.column_default is NULL Then NULL whenA.column_default= "' Then 'default" '" whenA.column_default is not NULL andA.data_typeinch('bigint','int','decimal') ThenConcat_ws ("','default', A.column_default) whenA.column_default is not NULL andA.data_typeinch('varchar','Char') ThenConcat_ws ("','default'," '", A.column_default," '") whenA.column_default is not NULL andA.data_typeinch('timestamp','datetime') ThenConcat_ws ("','default', A.column_default)Else NULL End ,'Comment" ", A.column_comment," '",';') AA frominformation_schema. ' COLUMNS ' awhereA.table_schema='Ibgs' andA.table_name='Sys_config';
Dynamically convert all column names in a table to lowercase