Retrieving Comments from a PostgreSQL DB

后端 未结 13 2159
别那么骄傲
别那么骄傲 2020-12-05 13:13

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

13条回答
  •  萌比男神i
    2020-12-05 13:46

    This works for me using the PostBooks 3.2.2 DB:

    select cols.column_name,
    (select pg_catalog.obj_description(oid) from pg_catalog.pg_class c where c.relname=cols.table_name) as table_comment
    ,(select pg_catalog.col_description(oid,cols.ordinal_position::int) from pg_catalog.pg_class c where c.relname=cols.table_name) as column_comment
    from information_schema.columns cols
    where cols.table_catalog='postbooks' and cols.table_name='apapply'
    

    Regards, Sylnsr

提交回复
热议问题