Unix Technical Forum

SQL to get a table columns comments?

This is a discussion on SQL to get a table columns comments? within the pgsql Hackers forums, part of the PostgreSQL category; --> Hi, What query can I run to get the comments for my table columns. i.e. the ones on my ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 06:44 AM
Timasmith
 
Posts: n/a
Default SQL to get a table columns comments?

Hi,

What query can I run to get the comments for my table columns.

i.e. the ones on my 8.1 database added with this command:

COMMENT ON COLUMN addresses.address_id IS 'Unique identifier for the
addresses table';

thanks

Tim

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 06:47 AM
codeWarrior
 
Posts: n/a
Default Re: SQL to get a table columns comments?

SELECT
CASE
WHEN sfl.description IS NOT NULL THEN sfl.description
WHEN sfl.description IS NULL THEN pa.attname::character varying
ELSE pd.description::character varying
END AS label
FROM ONLY pg_class pc
JOIN ONLY pg_attribute pa ON pc.oid = pa.attrelid AND pc.relnamespace =
2200:id AND pc.reltype > 0:id AND (pc.relkind = 'r'::"char" OR
pc.relkind = 'c'::"char" OR pc.relkind = 'v'::"char")
JOIN ONLY pg_type pt ON pa.atttypid = pt.oid
LEFT JOIN ONLY pg_description pd ON pc.oid = pd.objoid AND pa.attnum =
pd.objsubid
LEFT JOIN sys_flex_labels sfl ON pc.oid = sfl.table_oid:id AND
pa.attname::character varying::text = sfl.column_name::text
WHERE pa.attnum > 0
ORDER BY pc.relname::character varying, pa.attnum;



"Timasmith" <timasmith@hotmail.com> wrote in message
news:1169949426.721522.117610@a75g2000cwd.googlegr oups.com...
> Hi,
>
> What query can I run to get the comments for my table columns.
>
> i.e. the ones on my 8.1 database added with this command:
>
> COMMENT ON COLUMN addresses.address_id IS 'Unique identifier for the
> addresses table';
>
> thanks
>
> Tim
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:36 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com