1. 程式人生 > >MySql 查詢表結構信息

MySql 查詢表結構信息

ash 默認 comm sel The fault inf ati col

select Column_name as 列名,is_nullable as 是否可為空,data_type as 數據類型,column_default as 默認值,case when column_key =‘PRI‘ then ‘主鍵‘ when column_key =‘UNI‘ then ‘唯一約束‘ when column_key =‘MUL‘ then ‘可以重復‘ else ‘‘ end as 列鍵,column_comment as 字段說明 from information_schema.columns
where table_schema = ‘datashar‘ #表所在數據庫
and table_name = ‘departmentinfo‘ order by column_key desc ; #你要查的表

MySql 查詢表結構信息