pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noura Elhawary <nelhawar@redhat.com>
To: pgsql-sql@postgresql.org
Subject: what is the best way to get key information in postgres?
Date: Thu, 01 Mar 2007 10:48:17 +1000
Message-ID: <1172710097.3531.39.camel@scarecrow.brisbane.redhat.com> (raw)

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





Message-ID: <1172710097.3531.39.camel@scarecrow.brisbane.redhat.com>
Permalink:  ../1172710097.3531.39.camel@scarecrow.brisbane.redhat.com/
Also on:    postgresql.org/message-id/1172710097.3531.39.camel@scarecrow.brisbane.redhat.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: nelhawar@redhat.com
  Subject: Re: what is the best way to get key information in postgres?
  In-Reply-To: <1172710097.3531.39.camel@scarecrow.brisbane.redhat.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox