查询所有表名及表备注
Posted تHjkl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查询所有表名及表备注相关的知识,希望对你有一定的参考价值。
with tmp_tab as (
select pc.oid as ooid,pn.nspname,pc.*
from pg_class pc
left outer join pg_namespace pn
on pc.relnamespace = pn.oid
where 1=1
and pc.relkind in (\'r\')
and pn.nspname not in (\'pg_catalog\',\'information_schema\') -- select pn.oid, pn.* from pg_namespace pn where 1=1
and pn.nspname not like \'pg_toast%\'
and pc.oid not in (
select inhrelid
from pg_inherits
)
and pc.relname not like \'%peiyb%\'
order by pc.relname
),tmp_desc as (
select pd.*
from pg_description pd
where 1=1
and pd.objsubid = 0 --objsubid 对于一个表列上的一个注释,这里是列号(objoid和classoid指表自己)。对全部其余对象类型,此列为0。
--and pd.objoid=168605
)
select t0.*
from (
select tab.nspname,
tab.relname,
de.description,
\'comment on table \'||tab.nspname||\'.\'||tab.relname||\' is \'\'\'||de.description||\'\'\';\' as table_description
from tmp_tab tab
left outer join tmp_desc de
on tab.ooid = de.objoid
where 1=1
) t0
where 1=1
--and t0.description is not null
order by t0.nspname,t0.relname;
以上是关于查询所有表名及表备注的主要内容,如果未能解决你的问题,请参考以下文章
sqlite中SQLite查看所有表名及字段名,及判断是否存在的方法
sql server2008如何查询在指定的数据库中所有的表名和每个表的字段名及字段类型