Re: Find all instances of a column in the entire database. - Mailing list pgsql-sql

From Chris Browne
Subject Re: Find all instances of a column in the entire database.
Date
Msg-id 60d4nmfcej.fsf@dba2.int.libertyrms.com
Whole thread Raw
In response to Find all instances of a column in the entire database.  (Gavin 'Beau' Baumanis <gavinb@eclinic.com.au>)
List pgsql-sql
gavinb@eclinic.com.au ("Gavin 'Beau' Baumanis") writes:
> I am hoping that you might be able to give me some assistance with the
> following task!
> I have a database with nearly 200 tables and I need to find all tables
> that contain a column of myColumnName.
>
> I was hoping there might be a built-in function for this task, but I
> have been unable to find any information through our good friend Mr.
> Google or by perusing the fine manual.
>
> Thanks in advance for any thoughts you might have.

I have a schema which has a number of attributes called "name_id":

metadata=# select n.nspname, r.relname from pg_class r, pg_namespace n, pg_attribute a where a.attname = 'name_id' and
r.oid= attrelid and n.oid = relnamespace;nspname  |       relname       
 
----------+---------------------registry | redactedregistry | redactedregistry | redactedregistry | redactedregistry |
redactedregistry| redactedregistry | redactedregistry | redactedregistry | redactedregistry | redactedregistry |
redactedregistry| redactedregistry | redactedregistry | redactedregistry | redactedregistry | redactedregistry |
redactedregistry| redactedregistry | redactedregistry | redactedregistry | redactedregistry | redactedregistry |
redacted
(23 rows)

Change 'name_id' to 'myColumnName' and you should get what you're
expecting...
-- 
"cbbrowne","@","acm.org"
http://cbbrowne.com/info/lsf.html
Signs of a  Klingon Programmer -  17. "Klingon multitasking systems do
not  support "time-sharing". When a Klingon  program  wants to run, it
challenges the scheduler in hand-to-hand combat and owns the machine."


pgsql-sql by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Query tuning
Next
From: sumaya@silvermoongroup.com
Date:
Subject: dblinks