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

Home -> Community -> Usenet -> c.d.o.server -> Re: Unique constraint and NULL values

Re: Unique constraint and NULL values

From: Tony Andrews <andrewst_at_onetel.com>
Date: 21 Oct 2004 06:03:13 -0700
Message-ID: <1098363793.107241.90690@f14g2000cwb.googlegroups.com>


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

Original text of this message

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