Re: sql to get the column names of a table - Mailing list pgsql-general

From John Sidney-Woollett
Subject Re: sql to get the column names of a table
Date
Msg-id 1604.192.168.0.64.1074598475.squirrel@mercury.wardbrook.com
Whole thread Raw
In response to Re: sql to get the column names of a table  (Devrim GUNDUZ <devrim@gunduz.org>)
List pgsql-general
Devrim GUNDUZ said:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> Hi,
>
> On Tue, 20 Jan 2004, Alexander Antonakakis wrote:
>
>> How can I get the column names of a table with sql ?
>
>  SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg_%';
>
> will work, I think.


If you want COLUMNS and not TABLES and are using 7.4 then use the views
provided in the information_schema. eg

select column_name from information_schema.columns
where table_name = 'mytable';

Look at the view, you can select all sorts of info, and filter on other
criteria too.

John Sidney-Woollett



pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Foreign key constraint accepted even when not same
Next
From: "Eric Anderson Vianet SAO"
Date:
Subject: Re: sql to get the column names of a table