From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | Bill Todd <pg(at)dbginc(dot)com> |
Cc: | PgSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How relate pg_class to pg_constraint |
Date: | 2009-01-29 22:13:27 |
Message-ID: | 8763jxoj5k.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Bill Todd <pg(at)dbginc(dot)com> writes:
> I need to join pg_class and pg_constraint to get information about constraints
> on a table. It appears that pg_constraint.conrelid is the foreign key but I do
> not see a relid column in pg_class. What column(s) define the relationship
> between these tables? Thanks.
There's a system column called "oid" on all the system tables which is the
primary key. It doesn't show up unless you explicitly list it in the target
list of the select.
So you need a join like WHERE pg_class.oid = conrelid
If all you need is the name to display for users then there's a convenience
type called regclass which you can use by doing "SELECT conrelid::regclass
from pg_constraint". There are similar regtype and a few others like it too.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's 24x7 Postgres support!
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Diehl | 2009-01-29 22:57:16 | Call volume query |
Previous Message | Bill Todd | 2009-01-29 22:08:50 | Re: How relate pg_class to pg_constraint |