Re: Primary key reference count

Поиск
Список
Период
Сортировка
От Volkan YAZICI
Тема Re: Primary key reference count
Дата
Msg-id 20060419172117.GA206@alamut
обсуждение исходный текст
Ответ на Primary key reference count  (Wiebe Cazemier <halfgaar@gmx.net>)
Список pgsql-sql
On Apr 19 02:01, Wiebe Cazemier wrote:
> I'm trying to find which of the tables in pg_catalog contains the amount of
> references to a primary key, but I can't seem to find it.

Here's simple query, to list which table's which columns references to a
specific table. (Hope this is what you asked for.)

SELECT TBL.table_name, COL.column_name   FROM information_schema.referential_constraints AS REF   INNER JOIN
information_schema.table_constraintsAS TBL              USING (constraint_name)   INNER JOIN
information_schema.constraint_column_usageAS COL              USING (constraint_name)   INNER JOIN
information_schema.table_constraintsAS PRI              ON (PRI.constraint_name = REF.unique_constraint_name)   WHERE
PRI.table_name= 'pri_id'; -- Your target table goes here.
 

This is a quick & dirty hack. Just wanted to show the possibility of the
idea using information schema. (You don't want to deal with internal
tables, ain't?)


Regards.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Wiebe Cazemier
Дата:
Сообщение: Re: Primary key reference count
Следующее
От: Louise Catherine
Дата:
Сообщение: Field length ??