我要在选定的模式选择表得到期望的结果是这样PostgreSQL的,获得列名,列类型和描述
column_name | data_type | description
-----------------------------------------
id | integer | id of bill
name | character |
address | character | adress of buyer
注意,有些字段没有说明(列注释)。
现在我只拿到了这个查询,给了我很好的结果,但仅适用于有意见(对于那些在选定表中,并且没有评论在输出中没有代表列)列。
我的查询这对于有评论列返回唯一数据是下一个
SELECT c.column_name, c.data_type, 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)
where table_schema = 'public' and table_name = 'some_table';
如何获得列没有结果有何评论?
只是用'LEFT JOIN '。 'INNER JOIN'给你两个表的交集。如果表A中的行与表B没有关系,则该行将不会包含在输出中。 – KarelG
在发布问题之前尝试使用左连接,结果仍然相同 – KuKeC