Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to create a uniqueness constraint based on two fields?

Re: How to create a uniqueness constraint based on two fields?

From: Thomas Kellerer <NNGNVRDSJEBN_at_spammotel.com>
Date: Wed, 26 Jan 2005 13:46:29 +0100
Message-ID: <35php5F4i1sicU1@individual.net>


On 26.01.2005 13:25 Ramon wrote:

> I have read in this NG that there is a way to to have a
> uniqueness constraint based on two or more fields.
>
> Just to make sure that there are no confusions, I'll
> provide a very simple example. Suppose I am using SQL*Loader
> and there is a record with FIRST_NAME='JOHN' and LAST_NAME='SMITH'.
>
> Subsequent records with FIRST_NAME='JOHN' will be accepted.
> Subsequent records with LAST_NAME='SMITH' will be accepted.
>
> However, any record containing JOHN SMITH will be rejected for
> violating the constraint.
>
> TIA,
>
> -Ramon F Herrera
>

CREATE UNIQUE INDEX ON the_table (first_name, last_name);

should do it, I guess.

Thomas Received on Wed Jan 26 2005 - 06:46:29 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US