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

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

Re: composite Unique constraint and null

From: Stephane Faroult <sfaroult_at_roughsea.com>
Date: Tue, 18 Oct 2005 21:40:19 +0200
Message-Id: <1129664419.5407.20.camel@frlinux2.roughsea.com>


The interesting thing to know would be what you are supposed to do with 2,345,678 rows storing (1, null). I'd rather have one row with a counter, if the quantity matters.

SF

On Tue, 2005-10-18 at 12:24 -0700, Jared Still wrote:
> 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_at_gmail.com> 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
> >
> --
> http://www.freelists.org/webpage/oracle-l

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Oct 18 2005 - 14:41:16 CDT

Original text of this message

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