Oracle 11g重命名.保证是原子的? [英] Oracle 11g rename. Guaranteed to be atomic?

查看:77
本文介绍了Oracle 11g重命名.保证是原子的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在plsql脚本中有一些(5)重命名语句

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 ?

预先感谢

推荐答案

RENAME是DDL命令.因此,这就是单个离散事务,如果这就是您在此上下文中原子表示的意思.因此,它几乎是安全的.我无法想象重命名将如何导致您丢失数据.但是,如果您感到偏执,请记住,这就是《自然》为我们提供备份和恢复的原因.

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.

修改

如果DROP成功而RENAME失败,则确保不会丢失数据的方法是两次部署RENAME:

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.

这篇关于Oracle 11g重命名.保证是原子的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆