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

Home -> Community -> Mailing Lists -> Oracle-L -> composite Unique constraint and null

composite Unique constraint and null

From: Sandeep Dubey <dubey.sandeep_at_gmail.com>
Date: Tue, 18 Oct 2005 13:05:47 -0400
Message-ID: <bf2f74740510181005m1c562dc7ke88052af513ace1d@mail.gmail.com>


Hi,

I want to enforce a business rule on two columns such that col1, col2 should be unique. However for a given value of col1 nulls should be allowed in col2. I can not implement that using a simple composite unique constraint.

Eg.

create table foo(id number, name varchar2(10));

insert into foo values(1,1);
insert into foo values(1,1); -- should not be allowed

But following should be allowed

insert into foo values(1,null);
insert into foo values(1,null); -- should be allowed

Any ideas!!

Thanks

Sandeep
Sandeep

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Oct 18 2005 - 12:08:01 CDT

Original text of this message

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