我要在選定的模式選擇表得到期望的結果是這樣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