Home > Software engineering >  How to see a SQL table's comment in CLI?
How to see a SQL table's comment in CLI?

Time:01-27

Let say I have a schema world and a table city in a Postgres DB. I can set a comment on the table (or view, function, index, ...) with the command below:

COMMENT ON TABLE world.city IS 'This is a test comment';

How can I see this comment in CLI (Not GUI)? I tried using show command thinking it might help, but got a syntax error!

SHOW TABLE world.city;  
ERROR:  syntax error at or near "table"  
LINE 1: show table world.city;  

The same happened with show command on views!

CodePudding user response:

 \d  world.city

From the documentation:

The command form \d is identical, except that more information is displayed: any comments associated with the columns of the table are shown, as is the presence of OIDs in the table, the view definition if the relation is a view, a non-default replica identity setting and the access method name if the relation has an access method.

  •  Tags:  
  • Related