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 = '你的表名';
查询字段名、字段类型及字段长度和字段注释
select
a.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 "备注"
from
pg_attribute a
left join pg_description d on
d.objoid = a.attrelid
and d.objsubid = a.attnum
left join pg_class c on
a.attrelid = c.oid
left join pg_type t on
a.atttypid = t.oid
where
a.attnum >= 0
and c.relname like '表名'
order by
c.relname desc,
a.attnum asc
不同的数据库都是有的, 需要自己对应的查询一下的