Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to create a uniqueness constraint based on two fields?
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