How to retrieve a comment/description from a table

Поиск
Список
Период
Сортировка
Искать

How to retrieve a comment/description from a table

От:
Marcus Claesson <marcus.claesson@angiogenetics.se>
Дата:
Hello!
This psql command is very straight forward and promising:
COMMENT ON mytable IS 'This is my table.';

But how can I retrieve the particular comment from that table again?
Using \d+ gives you all the tables with their comments. I want a special
one.

And if that is not possible, can the \d+ results be obtained from a
system table or so?

Thanks,
Marcus

Re: How to retrieve a comment/description from a table

От:
Darren Ferguson <darren@crystalballinc.com>
Дата:
\d+ mytable will give you the comments for it

For system tables just do

\d+ pg_** substitute ** for system table name

HTH
On Fri, 23 Aug 2002, Marcus Claesson wrote:

> Hello!
> This psql command is very straight forward and promising:
> COMMENT ON mytable IS 'This is my table.';
> 
> But how can I retrieve the particular comment from that table again?
> Using \d+ gives you all the tables with their comments. I want a special
> one.
> 
> And if that is not possible, can the \d+ results be obtained from a
> system table or so?
> 
> Thanks,
> Marcus
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 

-- 
Darren Ferguson

Re: How to retrieve a comment/description from a table

От:
Marcus Claesson <marcus.claesson@angiogenetics.se>
Дата:
> \d+ mytable will give you the comments for it

This only gives me the same information as if I wrote '\d mytable', plus an
empty description column.  I couldn't see my comment anywhere.

What I wish is to retrieve the comment with a sql question, which would work
if the '\d+ information' could be found in an actual table somewhere.

Regards,
Marcus

Re: How to retrieve a comment/description from a table

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Marcus Claesson  writes:
> What I wish is to retrieve the comment with a sql question, which would work
> if the '\d+ information' could be found in an actual table somewhere.

The descriptions are kept in pg_description.  Although you can just do
"select from pg_description", the recommended retrieval method is the
obj_description() function.  See
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/functions-misc.html
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/catalog-pg-description.html

			regards, tom lane

Re: How to retrieve a comment/description from a table

От:
"Peter Gibbs" <peter@emkel.co.za>
Дата:
Marcus Claesson wrote:

> What I wish is to retrieve the comment with a sql question, which would
work
> if the '\d+ information' could be found in an actual table somewhere.

select obj_description(oid, 'pg_class')
  from pg_class
  where relname = 'tablename';
--
Peter Gibbs
EmKel Systems


Re: How to retrieve a comment/description from a table

От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Fri, 23 Aug 2002, Marcus Claesson wrote:

> > \d+ mytable will give you the comments for it
>
> This only gives me the same information as if I wrote '\d mytable', plus an
> empty description column.  I couldn't see my comment anywhere.
>
> What I wish is to retrieve the comment with a sql question, which would work
> if the '\d+ information' could be found in an actual table somewhere.

If you start psql with -E it will show you the queries it's running for
those backslash commands.

I believe \d+ table gives you column descriptions in that description
column.

FAQ