Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Not able to Insert duplicate rows even after using ENABLE NOVALIDATE constraint.

DINESH EDVINFeb 26 2016 — edited Mar 2 2016

Hi,

I was trying to insert duplicate rows in the "tbl_test" table. Initially i had two distinct rows in this table. I then created an Unique index and the Primary key constraint. Now am trying to insert duplicate rows in this table and i got an error stats that Unique constraint violated. I then disabled the Primary key constraint and enabled the NOVALIDATE constraint. Again i was trying to insert the duplicate row but still i got the same error. I know this error throws because of Unique index. I do not want to remove that Unique index. So is there any other possible ways to insert the duplicate rows. This is my query.

CREATE TABLE tbl_test ( col_1 NUMBER, Col_2 varchar(10));

--Table created.

INSERT INTO tbl_test VALUES (1,'XXX');

  --1 row(s) inserted.

INSERT INTO tbl_test VALUES (2,'YYY');

  --1 row(s) inserted.

CREATE UNIQUE INDEX idx_col_1 ON tbl_test(col_1);

--Index created.

ALTER TABLE tbl_test add constraint idx_col_1 PRIMARY KEY (col_1)

--Table altered.

INSERT INTO tbl_test VALUES (1,'XXX');

  --ORA-00001: unique constraint (HR.IDX_COL_1) violated

ALTER TABLE tbl_test DISABLE PRIMARY KEY

  --Table altered.

ALTER TABLE tbl_test ENABLE NOVALIDATE PRIMARY KEY

  --Table altered.

INSERT INTO tbl_test VALUES (1,'XXX');

  --ORA-00001: unique constraint (HR.IDX_COL_1) violated

This post has been answered by Aman.... on Feb 26 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2016
Added on Feb 26 2016
9 comments
1,703 views