I created a new table today in 10g when I noticed an interesting behavior. Here is an example of what I did:
CREATE TABLE test_table ( field_1 INTEGER PRIMARY KEY );
Oracle will create a nonzero unique index for the primary key by default. I double checked this. After a quick check, I find a unique index name SYS_C0065645. So far, everything is working as expected. Now I have done this:
CREATE TABLE test_table ( field_1 INTEGER,
CONSTRAINT pk_test_table PRIMARY KEY (field_1) USING INDEX (CREATE INDEX idx_test_table_00 ON test_table (field_1)));
After describing my newly created idx_test_table_00 index, I see that it is not unique. I tried to insert duplicate data into the table and was stopped by restricting the primary key, proving that the functionality was not affected. It seems strange to me that Oracle can use a non-ideal index to restrict the primary key. Why is this allowed?
source
share