mysql查询表字段设计和showdoc拼接语句


SELECT COLUMN_NAME 字段名,column_comment 字段描述 ,is_nullable 是否可空,data_type 字段类型,character_maximum_length 字段长度,column_type 字段类型 FROM INFORMATION_SCHEMA.Columns WHERE table_name='表名' AND table_schema='库名'

|序号|字段|类型|是否可空|默认|注释|
|:----|:-------|:--- |---|------|------|

SELECT CONCAT('|',ordinal_position,'|',COLUMN_NAME,'|',column_type,'|',(case is_nullable when 'YES' then '是' else '否' end),'|',ifnull(column_default,''),'|',column_comment,'|')
FROM INFORMATION_SCHEMA.Columns WHERE table_name='表名' AND table_schema='库名'