I'm trying to understand how Oracle determine if the index can be used for constraint. For example, the following works :
create table temp11
(id int not null,
val varchar2(10),
CONSTRAINT PK_temp11 primary key (id) using index
(create index IDX_temp11 ON temp11(id,val))
);
--Also, I can re-use the same index for another unique constraint :
ALTER TABLE temp11 ADD CONSTRAINT UQ_temp11 UNIQUE(id,val) using index IDX_temp11;
But if I change index definition and make it unique, I get error
ORA-14196: Specified index cannot be used to enforce the constraint.
create table temp11
(id int not null,
val varchar2(10),
CONSTRAINT PK_temp11 primary key (id) using index
(create UNIQUE index IDXU_temp11 ON temp11(id,val))
); -- ORA-14196
** Making val not null doesn't make a difference.
Could anyone explain this behaviour?
I don't see why such an unique index cannot used for enforcing constraint whereas non-unique is accepted.
I use Oracle 10 if it matters.