oracle 如何从表中分离分区并将其附加到oracle中的另一个?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9000355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to detach a partition from a table and attach it to another in oracle?
提问by azzaxp
I have a table with huge data( say millions of records, its just a case study though!) of 5 years, with a partition for each year. Now i would want to retain the last 2 years data, and transfer the rest of the 3 year data to a new table called archive?
我有一个包含大量数据的表(比如数百万条记录,但它只是一个案例研究!)5 年,每年有一个分区。现在我想保留过去 2 年的数据,并将剩余的 3 年数据转移到一个名为存档的新表中?
What would be the Ideal method, with minimal down time and high performance?
具有最少停机时间和高性能的理想方法是什么?
采纳答案by Florin Ghita
alter table exchange partition
is the answer. This command exange the segment of a partition with the segment of a table. It is at light speed because it does only some reference interchages. So, you need some temp tables, because AFAIK you can't exchange them directly.
是答案。此命令将分区的段与表的段进行交换。它是光速的,因为它只做一些参考交换。所以,你需要一些临时表,因为 AFAIK 你不能直接交换它们。
Something like:
就像是:
create table tmp_table(same columns);
Add partition p_2011 in table ARCH_TABLE;
ALTER TABLE CURR_TABLE EXCHANGE PARTITION P_2011 WITH TABLE tmp_table;
ALTER TABLE ARCH_TABLE EXCHANGE PARTITION P_2011 WITH TABLE tmp_table;
Please test test your code before run.
请在运行前测试您的代码。