Re: composite Unique constraint and null

  • From: Jared Still <jkstill@xxxxxxxxx>
  • To: dubey.sandeep@xxxxxxxxx
  • Date: Tue, 18 Oct 2005 12:24:00 -0700

A unique constraint can be used for this.

Have you tried it?

--
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist


On 10/18/05, Sandeep Dubey <dubey.sandeep@xxxxxxxxx> wrote:
> 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
>
--
//www.freelists.org/webpage/oracle-l

Other related posts: