pgsql可获取到对应的表名称、字段名称、注释、字段类型(GUASS的也是适用)
SELECT c.relname as 表名,a.attname as 字段名,format_type(a.atttypid,a.atttypmod) as 类型,a.attnotnull as 非空, col_description(a.attrelid,a.attnum) as 注释
FROM pg_class as c,pg_attribute as a
where a.attrelid = c.oid and a.attnum>0 and c.relname = '你的表名';
查询字段名、字段类型及字段长度和字段注释
selecta.attnum as "序号",c.relname as "表名",cast(obj_description(c.oid) as varchar) as "表名描述",a.attname as "列名",concat_ws('', t.typname, SUBSTRING(format_type(a.atttypid, a.atttypmod) from '\(.*\)')) as "字段类型",d.description as "备注"
frompg_attribute a
left join pg_description d ond.objoid = a.attrelidand d.objsubid = a.attnum
left join pg_class c ona.attrelid = c.oid
left join pg_type t ona.atttypid = t.oid
wherea.attnum >= 0and c.relname like '表名'
order byc.relname desc,a.attnum asc
不同的数据库都是有的, 需要自己对应的查询一下的