Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Unique constraint and NULL values
Yes, using a function-based unique index:
SQL> create unique index t1_uk on t1 ( case when b is not null then a end, b );
Index created.
SQL> insert into t1 values(1, null);
1 row created.
SQL> / 1 row created.
SQL> insert into t1 values(1, 1);
1 row created.
SQL> /
insert into t1 values(1, 1)
*
ERROR at line 1:
ORA-00001: unique constraint (TANDREWS.T1_UK) violated
Received on Thu Oct 21 2004 - 08:51:55 CDT