what is the best way to get key information in postgres?

Поиск
Список
Период
Сортировка
От Noura Elhawary
Тема what is the best way to get key information in postgres?
Дата
Msg-id 1172710097.3531.39.camel@scarecrow.brisbane.redhat.com
обсуждение исходный текст
Список pgsql-sql
Hi,

I want to know what is the best way to get all the keys(unique, primary,
foreign, multiple) for a table in postgres, I actually found this query
and i am not sure if it is the best way to get the keys info:

select r.relname as "Table", c.conname as "Constraint Name", contype as
"Constraint Type", conkey as "Key Columns", confkey as "Foreign
Columns", consrc as "Source" from pg_class r, pg_constraint c where
r.oid=c.conrelid and relname='tablename';


And if the above query is good, how can I display in the output the
column names that relates to the key.

Can I use that query to get The multiple key info? or what is the best
way to do so?


I will really appreciate your help.

Thanks, 

Noura Elhawary




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

Предыдущее
От: "Karthikeyan Sundaram"
Дата:
Сообщение: pg_dump inquiry
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: [GENERAL] Esay question, about the numeric format