select
t.table_schema ,t.table_name ,t.column_name,
pt.typname as column_type,
coalesce(character_maximum_length,numeric_precision,-1) as column_length,
numeric_scale as column_precision,
d.description as column_description
from
information_schema.columns t,
pg_attribute a,
pg_description d,
pg_class c,
pg_type pt,
pg_namespace pn
where
d.objoid=a.attrelid
and d.objsubid=a.attnum
and a.attname = t.column_name
and a.attnum > 0
and a.atttypid = pt.oid
and a.attrelid = c.oid
and c.relnamespace = pn."oid"
and c.relname = t.table_name
and pn.nspname = t.table_schema
and t.table_schema = '模式名称'
and t.table_name = '表名'
pg 获取列名称,类型,长度,精度,备注
于 2023-11-29 15:34:58 首次发布