Thursday, January 8, 2009

Creating Primary Key On Duplicate Values

Check out following:

SQL> select * from test;

COL1
———-
1
1
1
1
1

SQL> alter table test add constraint test_idx primary key(col1) disable;

Table altered.

SQL> create index test_idx on test(col1);

Index created.

SQL> alter table test enable novalidate constraint test_idx;

Table altered.

SQL> insert into test values(1);
insert into test values(1)
*
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.TEST_IDX) violated

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home