从PostgreSQL数据库中获取注释 [英] Retrieving Comments from a PostgreSQL DB

查看:100
本文介绍了从PostgreSQL数据库中获取注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Postgres数据库上运行一个项目,需要检索数据库中列的注释以用作表标题等.我已经看到有几个内置函数( pg_description col_description ),但我无法找到有关如何使用它们并与它们一起玩耍的例子被证明是徒劳的.

I'm running a project on a Postgres database and need to retrieve the comments on columns within the DB to be used as table headings and such. I have seen that there are a couple of built in functions (pg_description and col_description) but i haven't been able to find examples on how to use them and playing around with them has proved pretty futile.

所以我想知道是否有人能够做到这一点,如果可以,怎么办?

So I was wondering if any has been able to do this before and if so, how?

推荐答案

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);

这篇关于从PostgreSQL数据库中获取注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆