in psql if i do \d+, I get something like

 Schema |          Name           |   Type   | Owner  |    Size    |     Description 
 norsar | Routing Result          | table    | morten | 16 kB      | 
 norsar | Routing Result_id_seq   | sequence | morten | 8192 bytes | 

and so on. The last field, "Description" is always blank. Where does that field read its content? - and thereby, how can I set a description on a table? In some cases that could be quite useful - the same thing for description on columns that are shown if i do \d+ <tablename>.

I have tried \set ECHO_HIDDEN ON, but that didn't make it much clearer.


That shows comments that you define using the command comment on:

The following table definition:

create table foo
  id integer primary key, 
  name text not null

comment on table foo is 'This is the famous foo table';
comment on column foo.id is 'This is the primary key';
comment on column foo.name is 'This is the name of the thing';

Will then show up like this:

postgres> \d+
                                List of relations
 Schema |   Name    | Type  | Owner  |    Size    |         Description
 public | foo       | table | thomas | 8192 bytes | This is the famous foo table
(1 row)

postgres> \d+ foo
                                             Table "public.foo"
 Column |  Type   | Collation | Nullable | Default | Storage  | Stats target |          Description
 id     | integer |           | not null |         | plain    |              | This is the primary key
 name   | text    |           | not null |         | extended |              | This is the name of the thing
    "foo_pkey" PRIMARY KEY, btree (id)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.