pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Beth Gatewood <beth@vizxlabs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: query system tables to find columns unique constraint is constraining?
Date: Tue, 28 May 2002 15:10:33 -0400
Message-ID: <15686.1022613033@sss.pgh.pa.us> (raw)
In-Reply-To: <004a01c20678$0ee472d0$6901a8c0@bethvizx>
References: <004a01c20678$0ee472d0$6901a8c0@bethvizx>

"Beth Gatewood" <beth@vizxlabs.com> writes:
> I have been fiddling around trying to figure out which columns some unique
> constraints are constraining by querying  the system tables.....with zero
> luck.

Look at the pg_index row for the index that's implementing the
constraint.

Rather than messing with the pg_index entry directly, you might want to
use pg_get_indexdef(), which is a helper function for pg_dump:

regression=# create table foo (f1 int, constraint foo_f1 unique (f1));
NOTICE:  CREATE TABLE / UNIQUE will create implicit index 'foo_f1' for table 'foo'
CREATE TABLE
regression=# select pg_get_indexdef(oid) from pg_class where relname = 'foo_f1';
                  pg_get_indexdef
----------------------------------------------------
 CREATE UNIQUE INDEX foo_f1 ON foo USING btree (f1)
(1 row)


			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <15686.1022613033@sss.pgh.pa.us>
Permalink:  ../15686.1022613033@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15686.1022613033@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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, beth@vizxlabs.com
  Subject: Re: query system tables to find columns unique constraint is constraining?
  In-Reply-To: <15686.1022613033@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