Re: Find all instances of a column in the entire database.

Поиск
Список
Период
Сортировка
От Chris Browne
Тема Re: Find all instances of a column in the entire database.
Дата
Msg-id 60d4nmfcej.fsf@dba2.int.libertyrms.com
обсуждение исходный текст
Ответ на Find all instances of a column in the entire database.  (Gavin 'Beau' Baumanis <gavinb@eclinic.com.au>)
Список 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 по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Query tuning
Следующее
От: sumaya@silvermoongroup.com
Дата:
Сообщение: dblinks