Thanks for the question, Feng.
Asked: January 03, 2008 - 6:58 pm UTC
Last updated: January 03, 2008 - 7:13 pm UTC
Version: 9.2.8
Viewed 1000+ times
local@locbetar> create table a ( a number, constraint uk_a unique(a)); Table created. Elapsed: 00:00:00.06 local@locbetar> alter table a add constraint pk_a primary key (a) using index; alter table a add constraint pk_a primary key (a) using index * ERROR at line 1: ORA-02261: such unique or primary key already exists in the table Elapsed: 00:00:00.00 local@locbetar> alter table a add constraint pk_a primary key (a); alter table a add constraint pk_a primary key (a) * ERROR at line 1: ORA-02261: such unique or primary key already exists in the table Elapsed: 00:00:00.01 local@locbetar> alter table a add constraint pk_a primary key (a) enable novalidate; alter table a add constraint pk_a primary key (a) enable novalidate * ERROR at line 1: ORA-02261: such unique or primary key already exists in the table Elapsed: 00:00:00.00 local@locbetar> alter table a add constraint pk_a primary key (a) using index uk_a; alter table a add constraint pk_a primary key (a) using index uk_a * ERROR at line 1: ORA-02261: such unique or primary key already exists in the table
ops$tkyte%ORA10GR2> create table t ( x int, y int constraint y_unique unique ); Table created. ops$tkyte%ORA10GR2> insert into t select rownum, rownum from all_users; 59 rows created. ops$tkyte%ORA10GR2> commit; Commit complete. ops$tkyte%ORA10GR2> select table_name, index_name from user_indexes where table_name = 'T'; TABLE_NAME INDEX_NAME ------------------------------ ------------------------------ T Y_UNIQUE ops$tkyte%ORA10GR2><b> alter table t drop constraint y_unique KEEP INDEX;</b> Table altered. ops$tkyte%ORA10GR2> select table_name, index_name from user_indexes where table_name = 'T'; TABLE_NAME INDEX_NAME ------------------------------ ------------------------------ T Y_UNIQUE ops$tkyte%ORA10GR2> alter table t add constraint t_primary_key primary key(y); Table altered. ops$tkyte%ORA10GR2> select table_name, index_name from user_indexes where table_name = 'T'; TABLE_NAME INDEX_NAME ------------------------------ ------------------------------ T Y_UNIQUE ops$tkyte%ORA10GR2> drop index y_unique; drop index y_unique * ERROR at line 1: ORA-02429: cannot drop index used for enforcement of unique/primary key
Feng Qu, January 03, 2008 - 8:00 pm UTC
Share and learn SQL and PL/SQL; free access to the latest version of Oracle Database!
Classes, workouts and quizzes on Oracle Database technologies. Expertise through exercise!