Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Unique constraint and NULL values
Create a UNIQUE constraint and you are done:
SQL> create table t1 (a integer null unique);
Table created.
SQL> desc t1
Name Null? Type ------------------------------- -------- ---- A NUMBER(38)
SQL> insert into t1 values (1);
1 row created.
SQL> insert into t1 values (1);
insert into t1 values (1)
*
ERROR at line 1:
ORA-00001: unique constraint (TANDREWS.SYS_C00164508) violated
SQL> insert into t1 values (null);
1 row created.
SQL> insert into t1 values (null);
1 row created. Received on Thu Oct 21 2004 - 08:03:13 CDT