pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedColumns view? (Finding column names for a table)
2+ messages / 2 participants
[nested] [flat]
* Columns view? (Finding column names for a table)
@ 2008-02-06 20:33 Steve Midgley <public@misuse.org>
0 siblings, 1 reply; 2+ messages in thread
From: Steve Midgley @ 2008-02-06 20:33 UTC (permalink / raw)
To: pgsql-sql
Hi,
I see this documentation item but can't figure out how to use it:
http://www.postgresql.org/docs/8.2/interactive/infoschema-columns.html
>The view columns contains information about all table columns (or view
>columns) in the database.
However, if I execute "select columns;" I get a not found error. I'm
sure there's some simple explanation - I'm interested specifically in
listing the column names of a specific table (in Pg 8.2). The manual
SQL I've developed is (where [table_name] is the table I want columns
for):
select pg_attribute.attname, * from pg_attribute
join pg_class on pg_class.oid = pg_attribute.attrelid
where
pg_class.relname = '[table_name]'
and
attnum > 0
and atttypid > 0
Not pretty but seems to work. Of course if there were a view that
encapsulated this and future-proofed it, that'd be much nicer.
Any assistance is appreciated! Thanks,
Steve
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Columns view? (Finding column names for a table)
@ 2008-02-06 20:43 Thomas Kellerer <spam_eater@gmx.net>
parent: Steve Midgley <public@misuse.org>
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Kellerer @ 2008-02-06 20:43 UTC (permalink / raw)
To: pgsql-sql
Steve Midgley wrote on 06.02.2008 21:33:
> Hi,
>
> I see this documentation item but can't figure out how to use it:
>
> http://www.postgresql.org/docs/8.2/interactive/infoschema-columns.html
>
>> The view columns contains information about all table columns (or view
>> columns) in the database.
select column_name
from information_schema.columns
where table_name = 'table_name'
works for me.
Thomas
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-02-06 20:43 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-02-06 20:33 Columns view? (Finding column names for a table) Steve Midgley <public@misuse.org>
2008-02-06 20:43 ` Thomas Kellerer <spam_eater@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox