| From: | Michael Fuhr <mike(at)fuhr(dot)org> |
|---|---|
| To: | Jon Sime <jsime(at)mediamatters(dot)org> |
| Cc: | Jonathan Vanasco <postgres(at)2xlp(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: list all columns in db |
| Date: | 2007-06-08 02:24:47 |
| Message-ID: | 20070608022447.GA2575@winnie.fuhr.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, Jun 07, 2007 at 06:36:07PM -0400, Jon Sime wrote:
> select n.nspname as table_schema, c.relname as table_name,
> a.attname as column_name
> from pg_catalog.pg_attribute a
> join pg_catalog.pg_class c on (a.attrelid = c.oid)
> join pg_catalog.pg_namespace n on (c.relnamespace = n.oid)
> where c.relkind in ('r','v') and a.attnum > 0
> and n.nspname not in ('pg_catalog','information_schema')
> order by 1,2,3
Don't forget "and not a.attisdropped" else you might get something
like
table_schema | table_name | column_name
--------------+------------+------------------------------
public | foo | ........pg.dropped.2........
public | foo | col1
public | foo | col3
(3 rows)
--
Michael Fuhr
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kevin Hunter | 2007-06-08 03:31:14 | Re: [SQL] subtract a day from the NOW function |
| Previous Message | Guy Rouillier | 2007-06-08 02:00:59 | Re: Creditcard Number Security was Re: Encrypted column |