Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id CFA6D475A96 for ; Tue, 28 May 2002 15:14:22 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3044D476352 for ; Tue, 28 May 2002 15:10:37 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g4SJAXW15689; Tue, 28 May 2002 15:10:33 -0400 (EDT) To: "Beth Gatewood" Cc: pgsql-sql@postgresql.org Subject: Re: query system tables to find columns unique constraint is constraining? In-reply-to: <004a01c20678$0ee472d0$6901a8c0@bethvizx> References: <004a01c20678$0ee472d0$6901a8c0@bethvizx> Comments: In-reply-to "Beth Gatewood" message dated "Tue, 28 May 2002 11:47:02 -0700" Date: Tue, 28 May 2002 15:10:33 -0400 Message-ID: <15686.1022613033@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200205/300 X-Sequence-Number: 7935 "Beth Gatewood" 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