Skip to Main Content

SQL & PL/SQL

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!

is renaming a constraint a safe operation?

WestDraytonAug 30 2010 — edited Aug 30 2010
I have a big table and i want my script to rename its constraints, with script below.
Can this operation somehow "lock" my database objects or other way corrupt them? Maybe constraint is in use in datatabse by some DML-operation at that time when i execute the alter-statement, and i can recieve error ala "constraint is locked you cannot rename it!"? Or is it possible that when i run the rename-statement then i other sessions trying to do a DML operation on the table will recieve error ala "the table's constraint is being renamed you cannot do DML at this time"? Or is there any other bad thing that can happen when i try to rename constraints?

DECLARE
  CURSOR c_data IS SELECT * FROM All_Constraints WHERE Table_Name = 'T1';
BEGIN 
  FOR cur_rec IN c_data LOOP
    EXECUTE IMMEDIATE 'ALTER TABLE T1 RENAME CONSTRAINT ' || cur_rec.constraint_name || ' TO OLD_' || cur_rec.constraint_name;
  END LOOP;
END;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 27 2010
Added on Aug 30 2010
8 comments
1,319 views