Skip site navigation (1) Skip section navigation (2)

Re: Actual expression of a constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: lrotger <lrotger(at)aircomp(dot)aero>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Actual expression of a constraint
Date: 2006-02-06 18:05:49
Message-ID: 27878.1139249149@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-hackers
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

In response to

Responses

pgsql-hackers by date

Next:From: James William PyeDate: 2006-02-06 18:25:05
Subject: Re: Copy From & Insert UNLESS
Previous:From: Mohan KDate: 2006-02-06 17:44:34
Subject: Re: Postgres 8.1.x and MIT Kerberos 5

pgsql-admin by date

Next:From: Scott MarloweDate: 2006-02-06 18:37:53
Subject: Re: autovacuum
Previous:From: Mohan KDate: 2006-02-06 17:44:34
Subject: Re: Postgres 8.1.x and MIT Kerberos 5

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group