Re: Problem with enforcement of a 'UNIQUE' constraint

From: John Blackburn <jb2_at_qdot.qld.gov.au>
Date: 26 Feb 1995 23:24:51 GMT
Message-ID: <3ir2k3$1t3_at_camelot.qdot.qld.gov.au>


Carolyn Giberson (giber_at_pollux.cs.uga.edu) wrote:

> I'm working on an object-oriented front-end for Oracle as a thesis
> project and am observing curious behavior with enforcement of a
> 'UNIQUE' constraint on an attribute. Here is a short description of
> the behavior:
 

> If I create a table "by hand" like so:
> create table t1
> (n number UNIQUE NOT NULL);
 

> and attempt to insert records with duplicate values for 'n', Oracle
> complains about a constraint violation, as it should.
 

> If, however, I have my program construct the identical table creation
> command and send to Oracle, the table is apparently created without
> the 'UNIQUE' constraint. I can insert records with duplicate values
> for 'n', and Oracle does *not* complain.
 

> Can anyone suggest why I am observing this difference in behavior, and
> how I might persuade Oracle to enforce this constraint?

Try creating a unique index on the unique column:

create unique index x1 on t1 (n);

--
 
John Blackburn                                          Phone: +61 7 2534634
jb2_at_qdot.qld.gov.au                                     Fax:   +61 7 8541194
Received on Mon Feb 27 1995 - 00:24:51 CET

Original text of this message