![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
you could disable the constraint first and then change things and then reanable the constraint afterwards. |
#3
| |||
| |||
|
|
Hello world, I discovered a strange behavior when renaming primary and/or unique keys of an existing table in Oracle 9i (or maybe it's rather normal than strange, and I am simply doing something wrong). Normally, creating a primary key or unique key constraint will automatically also create an index with the same name and reference. I have tried to rename an existing primary key and an existing unique key like that: alter table mytable rename constraint pk111 to pk_mytable_id; alter table mytable rename constraint uk222 to uk_mytable_name; While the two CONSTRAINTS now do have the new names, the corresponding INDICES still have the old names. How can I rename both the constraints AND the corrsponding indices? I cannot simply rename the indices to the new names (as the destination name is already used), and I also cannot delete them (as they enforce a primary resp. unique key). So how to go? Jens |
#4
| |||
| |||
|
|
SQL> create table my_emp as select * from emp; SQL> create index my_emp on my_emp(empno); SQL> alter table my_emp add constraint my_emp check(deptno<100); |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Maxim Demenko wrote: SQL> create table my_emp as select * from emp; SQL> create index my_emp on my_emp(empno); SQL> alter table my_emp add constraint my_emp check(deptno<100); So far it's clear, but that does not involve renaming an existing primary key and index. I was out for an example of how to disable/reenable and rename both the constraint and index as you originally suggested. Jens Why should it be an exception ? |
#7
| |||
| |||
|
|
Tables, indexes and constraints resides in different namespaces, which means, you can have a table , index and constraint named the same. Hence , you can rename your index and constraints to the same identifier. |
|
I was out for an example of how to disable/reenable and rename both the constraint and index as you originally suggested. |
#8
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |