Getting list of table comments in PostgreSQL

前端 未结 3 1123
陌清茗
陌清茗 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:39

    All comments are stored in pg_description

    To get the comments on a table, you need to join it to pg_class

    As an alternative you can also use the function obj_description() to retrieve this information:

    SELECT obj_description(oid)
    FROM pg_class
    WHERE relkind = 'r'
    

    Edit

    In psql you can simply use the \d+ command to show all tables including their comments. Or use the \dd command to show all comments in the system

提交回复
热议问题