Dynamically convert all column names in a table to lowercase

Source: Internet
Author: User

/*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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.