我正在 Postgres 数据库上运行一个项目,需要检索数据库中列的注释以用作表标题等。我已经看到有几个内置函数(pg_描述 http://www.postgresql.org/docs/9.1/static/catalog-pg-description.html and 列描述 http://www.postgresql.org/docs/9.1/static/functions-info.html)但我一直无法找到如何使用它们的示例,并且事实证明使用它们是非常徒劳的。
所以我想知道以前是否有人能够做到这一点,如果可以的话,是如何做到的?
select
c.table_schema,
c.table_name,
c.column_name,
pgd.description
from pg_catalog.pg_statio_all_tables as st
inner join pg_catalog.pg_description pgd on (
pgd.objoid = st.relid
)
inner join information_schema.columns c on (
pgd.objsubid = c.ordinal_position and
c.table_schema = st.schemaname and
c.table_name = st.relname
);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)