From: | Chris Barnes <compuguruchrisbarnes(at)hotmail(dot)com> |
---|---|
To: | <dave(dot)gauthier(at)intel(dot)com>, Postgres General Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: pg view of table columns needed for scripting |
Date: | 2010-10-22 16:50:16 |
Message-ID: | BLU149-W3E175B31EEB21963884BDD45E0@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
From: dave(dot)gauthier(at)intel(dot)com
To: pgsql-general(at)postgresql(dot)org
Date: Fri, 22 Oct 2010 09:14:01 -0700
Subject: [GENERAL] pg view of table columns needed for scripting
Hi:
Is there something like a pg_xxx view that I can use to get
the column names and data types of a table, similar to what I see with \d ? I
need to run this is a script, so \d isn't viable. I did a \df and looked
around, but nothing popped out.
Thanks in Advance !
Specify the table name where like..
SELECT table_schema,table_name,column_name,data_type
FROM information_schema.columns
WHERE table_name like 't%'
and column_name = 'name_of_column_here' ORDER BY table_name
;
table_schema | table_name | column_name | data_type
---------------+-----------------------------------+---------------+-------------------
schema | table | column_name | character varying
Chris
From | Date | Subject | |
---|---|---|---|
Next Message | Miroslav Šulc | 2010-10-22 18:05:52 | Another PostgreSQL Diff Tool 2.3 released |
Previous Message | bricklen | 2010-10-22 16:38:34 | Re: pg view of table columns needed for scripting |