Re: Get all table names that have a specific column

From: Bricklen Anderson <BAnderson(at)PresiNET(dot)com>
To: emilu(at)cs(dot)concordia(dot)ca
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Get all table names that have a specific column
Date: 2005-09-30 15:37:19
Message-ID: 433D5BAF.307@PresiNET.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Emi Lu wrote:
> Greetings,
>
> I am not very familiar with the system views/tables in postgreSQL. I'd
> like to get all table names that have a column let's say named "col1".
>
> For example,
> t1 (... col1 varchar(3) ... )
> t2 (... col1 varchar(3) ... )
> t3 (... ...)
>
>
> After querying the system tables/views, I can get the result something
> like :
>
> tables contain column "col1"
> ---------------------------------------------
> t1
> t2
> (2 rows)
>
>
> Thanks a lot,
> Emi
Check this posting:
http://archives.postgresql.org/pgsql-admin/2005-03/msg00011.php

Query the pga_columns view for the matches that you are looking for.
eg:
select tablename
from pga_columns
where columnname='col1';

--
_______________________________

This e-mail may be privileged and/or confidential, and the sender does
not waive any related rights and obligations. Any distribution, use or
copying of this e-mail or the information it contains by other than an
intended recipient is unauthorized. If you received this e-mail in
error, please advise me (by return e-mail or otherwise) immediately.
_______________________________

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug Bloebaum 2005-09-30 15:41:20 Re: Get all table names that have a specific column
Previous Message A. Kretschmer 2005-09-30 15:30:04 Re: Get all table names that have a specific column