如下图SQL所示
select a.attnum AS 序号,
-- 这里是表描述,原本新建数据库的时候没有添加表描述,查询出来会为空,注释掉就好,有表描述的放开这条注释
a.attname AS 字段名称,
concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as 字段类型,
a.attnotnull as 是否为null,
d.description AS 备注
from pg_class c, pg_attribute a , pg_type t, pg_description d
-- 这里是你的表名
where c.relname ='t_order_trip_scheduling'
and a.attnum>=0
and a.attrelid = c.oid
and a.atttypid = t.oid
and d.objoid=a.attrelid
and d.objsubid=a.attnum
ORDER BY c.relname DESC,a.attnum ASC