Re: Actual expression of a constraint

From: lrotger <lrotger(at)aircomp(dot)aero>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Actual expression of a constraint
Date: 2006-02-07 15:33:55
Message-ID: 43E8BDE3.6000802@aircomp.aero
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-hackers

Tom Lane wrote:
> lrotger <lrotger(at)aircomp(dot)aero> writes:
>
>>I know I could dig this out of the manuals so don't be too hard on me,
>>I'd like to know how to query the actual text of the expression of a
>>constraint. I know the name of the constraint and of the table.
>
>
> Something like this:
>
> regression=# create table t1 (f1 int constraint c1 check (f1 > 0));
> CREATE TABLE
> regression=# select pg_get_constraintdef(c.oid)
> regression-# from pg_constraint c join pg_class t on c.conrelid = t.oid
> regression-# where t.relname = 't1' and c.conname = 'c1';
> pg_get_constraintdef
> ----------------------
> CHECK ((f1 > 0))
> (1 row)
>
> You can probably also get it from the information_schema.
>
> regards, tom lane
>

I forgot to mention that my version is 7.2.1. I replaced the column
names for the ones I see in my installation hoping it would work but the
function, pg_get_conbstraintdef() doesn't exist.

I see that information_schema was introduced in 8.0 too.

Anyway I found out that \d table shows the table definition so it's solved.

Thanks a lot
L Rotger

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2006-02-07 16:01:21 Re: Actual expression of a constraint
Previous Message Michael Stone 2006-02-07 14:20:08 Re: Default autovacuum settings too conservative

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-02-07 15:34:22 Re: Sequences/defaults and pg_dump
Previous Message Csaba Nagy 2006-02-07 15:27:24 Re: streamlined standby procedure