I have some (5) rename statements in a plsql script
drop table new;
rename old to new;
"old" tables hold very valuable information.
As I see it, if the rename command is guaranteed to be atomic, then I´d have one problem solved.
Is it atomic? If not, is there a way to do a "safe" rename ?
Thanks in advance
RENAME
is a DDL command. So it is a single discrete transaction, if that's what you mean by atomic in this context. Consequently it is about as safe as anything could be. I can't imagine how a renaming would cause you to lose your data. But if you're feeling paranoid, just remember that's why Nature gave us backup and recovery.
edit
The way to be sure you don't lose data if the DROP
succeeds and the RENAME
fails is to deploy RENAME
twice:
SQL> rename old_table to something_else;
SQL> rename new_table to old_table;
SQL> drop table something_else;
That way you have your data online. This also minimises the downtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With