pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: lrotger <lrotger@aircomp.aero>
Cc: pgsql-admin@postgresql.org
Subject: Re: Actual expression of a constraint
Date: Mon, 06 Feb 2006 13:05:49 -0500
Message-ID: <27878.1139249149@sss.pgh.pa.us> (raw)
In-Reply-To: <43E71F51.7030108@aircomp.aero>
References: <43E71F51.7030108@aircomp.aero>

lrotger <lrotger@aircomp.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



view thread (9+ messages)  latest in thread

Message-ID: <27878.1139249149@sss.pgh.pa.us>
Permalink:  ../27878.1139249149@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27878.1139249149@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lrotger@aircomp.aero
  Subject: Re: Actual expression of a constraint
  In-Reply-To: <27878.1139249149@sss.pgh.pa.us>
  References: <43E71F51.7030108@aircomp.aero> <27878.1139249149@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox