select a.attnum,
a.attname AS field,
c.relname as relname,
t.typname AStype,
a.attlen AS length,
a.atttypmod AS lengthvar,
a.attnotnull AS notnull,
b.description AScommentfrom pg_class c,pg_attribute a
LEFTOUTERJOIN pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid,pg_type t
WHERE1=1--and c.relname = 'udoc_saldiscount' and a.attname ='productseriescode'and a.attnum >0and a.attrelid = c.oid
and a.atttypid = t.oid
ORDERBY a.attnum
limit100
2、查询表名称
psql方式查询表名称
\dt
sql方式查看表名称
select tablename FROM pg_tables;-- select tablename from pg_tables where schemaname='public'
sql 方式视图名称查询
SELECT viewname FROM pg_views WHERE schemaname ='public'
-- 根据字段名查询所在表SELECT a.attnum as"字段名",
a.attname AS field,
c.relname as"表名",
t.typname AStype,
a.attlen AS length,
a.atttypmod AS lengthvar,
a.attnotnull AS notnull,
b.description AScomment,
c.oid as oid
FROM pg_class c,pg_attribute a
LEFTOUTERJOIN pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid,pg_type t
WHERE1=1--and c.relname = 'udoc_saldiscount' and a.attname ='productseriescode'and c.relname NOTLIKE'pg_%'and a.attnum >0and a.attrelid = c.oid
and a.atttypid = t.oid
ORDERBY a.attnum
limit100
其他
select tablename from pg_tables where schemaname='public'