Getting list of table comments in PostgreSQL

前端 未结 3 1128
陌清茗
陌清茗 2020-12-09 01:52

Postgresql allows adding comments to objects such as tables. For example I\'ve added a comment to table \"mytable\" by using this SQL command:

COMMENT ON TAB         


        
3条回答
  •  温柔的废话
    2020-12-09 02:53

    You can use pg_catalog.obj_description function and information_schema.tables schema view:

    SELECT t.table_name, pg_catalog.obj_description(pgc.oid, 'pg_class')
    FROM information_schema.tables t
    INNER JOIN pg_catalog.pg_class pgc
    ON t.table_name = pgc.relname 
    WHERE t.table_type='BASE TABLE'
    AND t.table_schema='public';
    

    FUNCTIONS-INFO-COMMENT-TABLE

    INFORMATION_SCHEMA Support in MySQL, PostgreSQL

提交回复
热议问题