zoukankan      html  css  js  c++  java
  • 动态将表中的列名全部转换成小写

    /*
      动态将表的列名改为小写
    */
    select concat_ws('','alter table ',a.TABLE_NAME,' modify ',lower(a.COLUMN_NAME),' ',a.Column_type, case when a.is_nullable = 'NO' THEN ' not null ' else null end,
           case when a.Column_default is null then null
                when a.Column_default = '' then ' default '''''
                when a.Column_default is not null and a.data_type in ('bigint','int','decimal') then  concat_ws('',' default ',a.Column_default)
                when a.Column_default is not null and a.data_type in ('varchar','char') then  concat_ws('',' default ','''',a.Column_default,'''')
                when a.Column_default is not null and a.data_type in ('timestamp','datetime') then  concat_ws('',' default ',a.Column_default) 
           else null end     
           ,' comment ''',a.Column_comment,'''',';') aa
      from information_schema.`COLUMNS` a 
     where a.TABLE_SCHEMA ='ibgs'
       and a.TABLE_NAME ='sys_config';
  • 相关阅读:
    linux_进程管理
    Linux-日志管理
    Httpd
    Linux-源码安装包管理
    Linux-计划任务管理
    Linux-LVM管理
    Linux-系统磁盘管理
    Linux-yum工具的使用
    Linux-rpm包管理
    Linux-网络进阶管理
  • 原文地址:https://www.cnblogs.com/Yongzhouunknown/p/4900616.html
Copyright © 2011-2022 走看看