Re: How can I select a comment on a column in a query?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: George Weaver <gweaver(at)shaw(dot)ca>
Cc: A u r k a <aurka(at)centrum(dot)cz>, pgsql-novice(at)postgresql(dot)org
Subject: Re: How can I select a comment on a column in a query?
Date: 2004-01-19 15:54:03
Message-ID: 28332.1074527643@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

George Weaver <gweaver(at)shaw(dot)ca> writes:
> test=# select description from pg_description where objoid = 306461 and
> objsubid = 0;

Also, there is a col_description() function that encapsulates this
query. I'd recommend col_description() and its sibling obj_description()
in preference to examining the pg_description catalog directly. See
"Comment Information Functions" in
http://www.postgresql.org/docs/7.4/static/functions-misc.html

Here's a simple example:

regression=# create table mytab (mycol int);
CREATE TABLE
regression=# comment on column mytab.mycol is 'my comment';
COMMENT
regression=# select col_description('mytab'::regclass, 1);
col_description
-----------------
my comment
(1 row)

(I'm using the regclass datatype as a substitute for an explicit
lookup in pg_class to get the OID of the table. This feature is
new since 7.3 or thereabouts.)

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Lduren02 2004-01-19 20:09:47 absolute beginner
Previous Message George Weaver 2004-01-19 15:41:46 Re: How can I select a comment on a column in a query?