Re: query system tables to find columns unique constraint is constraining?

Lists: pgsql-sql
From: "Beth Gatewood" <beth(at)vizxlabs(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: query system tables to find columns unique constraint is constraining?
Date: 2002-05-28 18:47:02
Message-ID: 004a01c20678$0ee472d0$6901a8c0@bethvizx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hi-

I have been fiddling around trying to figure out which columns some unique
constraints are constraining by querying the system tables.....with zero
luck.

Can anyone suggest how to do this?

thank!
Beth


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Beth Gatewood" <beth(at)vizxlabs(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: query system tables to find columns unique constraint is constraining?
Date: 2002-05-28 19:10:33
Message-ID: 15686.1022613033@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

"Beth Gatewood" <beth(at)vizxlabs(dot)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


From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Beth Gatewood" <beth(at)vizxlabs(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: query system tables to find columns unique constraint is constraining?
Date: 2002-05-28 21:12:28
Message-ID: 03e801c2068c$5fb41260$3200a8c0@internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

It's all in the pg_index table. Check for unique indices.

Chris

----- Original Message -----
From: "Beth Gatewood" <beth(at)vizxlabs(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Sent: Tuesday, May 28, 2002 11:47 AM
Subject: [SQL] query system tables to find columns unique constraint is
constraining?

>
>
> Hi-
>
> I have been fiddling around trying to figure out which columns some unique
> constraints are constraining by querying the system tables.....with zero
> luck.
>
> Can anyone suggest how to do this?
>
> thank!
> Beth
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>