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: relationship between unique index and constraint

RE: relationship between unique index and constraint

From: Jacques Kilchoer <Jacques.Kilchoer_at_quest.com>
Date: Fri, 18 Apr 2003 10:51:47 -0800
Message-ID: <F001.00584FEF.20030418105147@fatcity.com>


I suppose you could say the messge is misleading. It's the unique index that is being "violated".
The reverse is true however: if you create a unique constraint, then an enforcing unique index will be automatically created for you (unless you already have an index on those columns.)

> -----Original Message-----
> From: Ehresmann, David [mailto:David.Ehresmann_at_ps.net]
>
> If I create a unique index does Oracle create the unique constraint?
>
> Example:
>
> sql>create unique index name
> on dept(dname);
>
> index created.
>
> sql>select constraint_name from user_constraints;
>
> no rows selected.
>
> sql>insert into dept(deptno, dname, loc)
> values(99,'SALES', 'DALLAS');
>
> ORA-00001: unique constraint (djehres.dname) violated.
>
> sql>select constraint_name from user_constraints;
>
> no rows selected.
>
>
> Question: If Oracle does not create a unique constraint (
> does not show up
> in user_constraints) when you create a unique index how do
> you end up with
> a UNIQUE CONSTRAINT VIOLATED error?

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jacques Kilchoer
  INET: Jacques.Kilchoer_at_quest.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Fri Apr 18 2003 - 13:51:47 CDT

Original text of this message

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