zoukankan      html  css  js  c++  java
  • mysql 查询表字段名,注释 , 以及sql拼接查询出的内容

    #sql查询字段名,注释操作拼接

    #查询字段名和注释  
    select COLUMN_NAME,COLUMN_COMMENT from information_schema.COLUMNS where table_name = '表名' and table_schema = '库名' order by ordinal_position 
    #查询整个内容
    select * from information_schema.COLUMNS where table_name = '表名' and table_schema = '库名' order by ordinal_position 
    
    
    #拼接  group_concat(field,SEPARATOR '拼接字符')  
    select group_concat(COLUMN_NAME SEPARATOR ';'),group_concat(COLUMN_COMMENT SEPARATOR ';') from information_schema.COLUMNS where table_name = '表名' and table_schema = '库名' order by ordinal_position 
    
    #按顺序排字段拼接 group_concat(field order by field,SEPARATOR '字符')
    select group_concat(COLUMN_NAME order by ordinal_position SEPARATOR ';'),group_concat(COLUMN_COMMENT ORDER BY ordinal_position SEPARATOR ';') from information_schema.COLUMNS where table_name = '表名' and table_schema = '库名' order by ordinal_position 
    
    #整个库下的所有表
    select TABLE_NAME,group_concat(COLUMN_NAME order by ordinal_position SEPARATOR ';'),group_concat(COLUMN_COMMENT ORDER BY ordinal_position SEPARATOR ';') from information_schema.COLUMNS where table_schema = '库名'  GROUP BY TABLE_NAME
    
    
    #整个服务器下的所有库中表,每个表的字段和注释的拼接
    select TABLE_SCHEMA,TABLE_NAME,group_concat(COLUMN_NAME order by ordinal_position SEPARATOR ';'),group_concat(COLUMN_COMMENT ORDER BY ordinal_position SEPARATOR ';') from information_schema.COLUMNS   GROUP BY TABLE_NAME,TABLE_SCHEMA ORDER BY TABLE_SCHEMA
  • 相关阅读:
    系统架构设计师软考总结
    统一用户认证系统CUAS实现要点
    Activiti使用总结
    性能优化总结篇
    CVE-2016-5734-phpmyadmin-4.0.x-4.6.2-代码执行
    WooYun-2016-199433 -phpmyadmin-反序列化-getshell
    CVE-2015-1635-HTTP.SYS远程执行代码
    泛微OA 多版本存在命令执行
    CVE-2019-20372-Nginx error_page 请求走私
    通达OA 页面敏感信息-2013/2015版本
  • 原文地址:https://www.cnblogs.com/HugJun/p/12067172.html
Copyright © 2011-2022 走看看