unique constraint on 2 columns

From: Jonathan Vanasco <postgres(at)2xlp(dot)com>
To: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: unique constraint on 2 columns
Date: 2007-04-20 20:52:37
Message-ID: 16BE9D41-D328-4F9F-A7D2-623388239D1E@2xlp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need a certain unique constraint in pg that i can't figure out.

Given:

create table test_a (
id serial ,
name_1 varchar(32) ,
name_2 varchar(32)
);

I need name_1 and name_2 to both be unique so that:
name_1 never appears in name_1 or name_2
name_2 never appears in name_2 or name_1

a standard 2 column unique index / constraint will not accomplish this.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Godoy 2007-04-20 21:04:58 Re: unique constraint on 2 columns
Previous Message Douglas McNaught 2007-04-20 18:58:02 Re: Upgrading a 32-bit build to a 64-bit build