How can I select a comment on a column?
How can I select a comment on a column?
От:
Serguei Pronkine <pronkine@krikri.de>
Дата:
Hi community,
I'd like to retrieve comments on tables an columns by table name and
column name. The posting by Tom Lane
http://archives.postgresql.org/pgsql-novice/2004-01/msg00180.php?adv=1
says how to select comment on a column.
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)
How can I now retrieve column number from column name?
Thanks in advance,
Serguei Pronkine
Re: How can I select a comment on a column?
От:
Michael Fuhr <mike@fuhr.org>
Дата:
On Mon, Mar 26, 2007 at 04:37:59PM +0200, Serguei Pronkine wrote: > How can I now retrieve column number from column name? Query pg_attribute. http://www.postgresql.org/docs/8.2/interactive/catalog-pg-attribute.html Since psql can display object comments you could study the SQL that it executes: \set ECHO_HIDDEN \d+ mytab -- Michael Fuhr