#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