Re: getting comment about constraint

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: canfieldsteve(at)hotmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: getting comment about constraint
Date: 2006-06-22 13:42:14
Message-ID: 20060622134214.GA31359@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jun 18, 2006 at 03:02:05PM -0700, canfieldsteve(at)hotmail(dot)com wrote:
> Given the name of the table and constraint, how would you retrieve the
> comment? "Chapter 9. Functions and Operators" says that
> obj_description(object_oid, catalog_name) returns a comment given the
> object's OID and class name. How do I get the OID for the constraint?
> It doesn't seem to be stored in pg_constraint.

How did you determine that? Are you aware that oid is a system
column that isn't ordinarily displayed? The following works in
every version of PostgreSQL I checked (7.3.15, 7.4.13, 8.0.8, 8.1.4,
8.2devel):

SELECT obj_description(oid, 'pg_constraint')
FROM pg_constraint
WHERE conname = 'constraint_name'
AND conrelid = 'table_name'::regclass;

Replace constraint_name and table_name with the actual names
(uid_alphanumeric and people in the example you gave).

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moseley 2006-06-22 13:44:14 Re: Missing domain socket after reboot.
Previous Message Kenneth Downs 2006-06-22 12:40:26 Re: Form builder?