MySql 查询表结构信息

时间:2023-03-08 19:58:31
MySql  查询表结构信息

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 ; #你要查的表