X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 5F0AA9DC9CD for ; Tue, 7 Feb 2006 11:33:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81646-10 for ; Tue, 7 Feb 2006 11:33:59 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.aircomp.aero (60.Red-80-36-217.staticIP.rima-tde.net [80.36.217.60]) by postgresql.org (Postfix) with ESMTP id EBF9E9DC859 for ; Tue, 7 Feb 2006 11:33:52 -0400 (AST) Received: from [192.168.0.101] (unknown [192.168.0.101]) by smtp.aircomp.aero (Postfix) with ESMTP id 9065443A88; Tue, 7 Feb 2006 16:34:13 +0100 (CET) Message-ID: <43E8BDE3.6000802@aircomp.aero> Date: Tue, 07 Feb 2006 16:33:55 +0100 From: lrotger Organization: AIRCOMP, SL User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-admin@postgresql.org Subject: Re: Actual expression of a constraint References: <43E71F51.7030108@aircomp.aero> <27878.1139249149@sss.pgh.pa.us> In-Reply-To: <27878.1139249149@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200602/66 X-Sequence-Number: 20487 Tom Lane wrote: > lrotger 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