Re: Finding the Table for Check Constraint

From: Brent Dombrowski <brent(dot)dombrowski(at)gmail(dot)com>
To: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
Cc: Postgresql PDX_Users <pdxpug(at)postgresql(dot)org>
Subject: Re: Finding the Table for Check Constraint
Date: 2012-05-08 17:41:09
Message-ID: E3C38B14-AC18-4EC5-8CA0-6890FDE150B9@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pdxpug

Thank you. n.oid is what I was missing.

Brent.

On May 8, 2012, at 10:21 AM, David E. Wheeler wrote:

> On May 8, 2012, at 10:08 AM, Brent Dombrowski wrote:
>
>> I need to update some check constraints for a postgis migration. I can find the constraints I'm interested in the the pg_constraint catalog. However, I'm having a hell of a time trying to get the table name associated with the constraint. I can get the schema name and the column is included in the source, but the table is eluding me. Anyone have a clue they could send my way?
>
> Join pg_constraint.conrelid to pg_class:
>
> SELECT n.nspname, c.relname
> FROM pg_catalog.pg_namespace n
> JOIN pg_catalog.pg_class c ON c.relnamespace = n.oid
> JOIN pg_catalog.pg_constraint x ON c.oid = x.conrelid;
>
> HTH,
>
> David

In response to

Browse pdxpug by date

  From Date Subject
Next Message gabrielle 2012-05-15 12:58:59 May meeting this Thursday
Previous Message Tim Bruce 2012-05-08 17:22:48 Re: Finding the Table for Check Constraint