what is the best way to get key information in postgres? - Mailing list pgsql-sql

From Noura Elhawary
Subject what is the best way to get key information in postgres?
Date
Msg-id 1172710097.3531.39.camel@scarecrow.brisbane.redhat.com
Whole thread Raw
List 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 by date:

Previous
From: "Karthikeyan Sundaram"
Date:
Subject: pg_dump inquiry
Next
From: Bruno Wolff III
Date:
Subject: Re: [GENERAL] Esay question, about the numeric format