dbTalk Databases Forums  

Re: looking for a query to get all constraints of a table and its columns

comp.databases.postgresql comp.databases.postgresql


Discuss Re: looking for a query to get all constraints of a table and its columns in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: looking for a query to get all constraints of a table and its columns - 03-01-2007 , 10:49 AM






Sascha Bohnenkamp <bohnenkamp (AT) mevisbreastcare (DOT) de> wrote:
Quote:
I am looking for a query to get all constraints of a table and its columns.
We sometime need such information
Are you looking for something like this:

SELECT t.relname AS table, conkey AS columns, conname,
contype, f.relname AS destination
FROM pg_constraint AS c JOIN pg_class AS t ON (t.oid = c.conrelid)
LEFT OUTER JOIN pg_class f ON (c.confrelid = f.oid)
WHERE t.relname='anyoldtablename';

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.