Thread: How can I select all of the tables with field name 'area'?

How can I select all of the tables with field name 'area'?

From
"G. Anthony Reina"
Date:
I have a database with several tables. I'd like to pull out a list of
names for the tables that contain the field (class) name 'area'.

Can this be done?

-Tony




RE: How can I select all of the tables with field name 'area'?

From
"Stuart Foster"
Date:
You should be able to query the system table that holds that column names.
Not sure which it is tho.

-----Original Message-----
From: pgsql-sql-owner@hub.org [mailto:pgsql-sql-owner@hub.org]On Behalf
Of G. Anthony Reina
Sent: Monday, September 11, 2000 4:38 PM
To: pgsql-sql@postgreSQL.org
Subject: [SQL] How can I select all of the tables with field name
'area'?


I have a database with several tables. I'd like to pull out a list of
names for the tables that contain the field (class) name 'area'.

Can this be done?

-Tony





Re: How can I select all of the tables with field name 'area'?

From
"Darrin Ladd"
Date:
Here's what you are looking for:

SELECT pg_class.relname
FROM pg_class, pg_attribute
WHERE pg_attribute.attname = 'area'
AND pg_attribute.attrelid = pg_class.oid;

This should give you all of the classes (tables) which have the attribute
(field) 'area'.

Cheers,
Darrin

-----Original Message-----
From: Stuart Foster <stuartafoster@home.com>
To: G. Anthony Reina <reina@nsi.edu>; pgsql-sql@postgreSQL.org
<pgsql-sql@postgreSQL.org>
Date: Monday, September 11, 2000 7:03 PM
Subject: RE: [SQL] How can I select all of the tables with field name
'area'?


>You should be able to query the system table that holds that column names.
>Not sure which it is tho.
>
>-----Original Message-----
>From: pgsql-sql-owner@hub.org [mailto:pgsql-sql-owner@hub.org]On Behalf
>Of G. Anthony Reina
>Sent: Monday, September 11, 2000 4:38 PM
>To: pgsql-sql@postgreSQL.org
>Subject: [SQL] How can I select all of the tables with field name
>'area'?
>
>
>I have a database with several tables. I'd like to pull out a list of
>names for the tables that contain the field (class) name 'area'.
>
>Can this be done?
>
>-Tony
>
>
>



Re: How can I select all of the tables with field name 'area'?

From
"G. Anthony Reina"
Date:
Thanks Darrin and Stuart.

-Tony




Darrin Ladd wrote:

> Here's what you are looking for:
>
> SELECT pg_class.relname
> FROM pg_class, pg_attribute
> WHERE pg_attribute.attname = 'area'
> AND pg_attribute.attrelid = pg_class.oid;
>
> This should give you all of the classes (tables) which have the attribute
> (field) 'area'.
>
>