This is expected behavior as seen in the following example:
create table test_con(
c1 varchar2(10),
c2 number,
c3 date,
c4 varchar2(10));
create index idx1 on test_con(upper(c4)); <---Index is created using the upper function on column c4
Index created
alter table test_con add constraint test_con_u1 unique(c4) using index idx1 enable novalidate; <---error is raised
ERROR at line 1:
ORA-14196: Specified index cannot be used to enforce the constraint.
--alter table test_con add constraint test_con_u1 unique(c4) 直接这个会新建一个unique index 和key
select column_name from user_ind_columns where index_name = 'IDX1';
COLUMN_NAME
--------------------------------------------------------------------------------
SYS_NC00005$
SQL> alter table test_con add constraint test_con_u1 unique("SYS_NC00005$") using index idx1 enable novalidate;
Table altered.
ALTER TABLE SYSTEM.TEST_CON ADD (
CONSTRAINT TEST_CON_U1
UNIQUE (SYS_NC00005$)
USING INDEX system.IDX1----ORA-00907: missing right parenthesis --no need system.
ENABLE VALIDATE);
-----------PK enable时自动非空,但是novalidate时不自动--disable validate 也是强制非空的----
SQL> alter table TEST_CON modify constraint TEST_CON_PK1 enable novalidate;
Table altered
SQL> desc TEST_CON
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
C1 VARCHAR2(10) Y
C2 NUMBER Y
C3 DATE Y
C4 VARCHAR2(10) Y
SQL> alter table TEST_CON modify constraint TEST_CON_PK1 enable;
Table altered
SQL> desc TEST_CON
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
C1 VARCHAR2(10) Y
C2 NUMBER Y
C3 DATE Y
C4 VARCHAR2(10)
SQL>