Home  >  Article  >  Database  >  快速转移数据的方法

快速转移数据的方法

WBOY
WBOYOriginal
2016-06-07 17:53:361224browse

如果你要把ORACLE里的大量数据(80M以上)转移到另外的用户,另外的表空间里。可以用下面介绍的快速转移 数据的方法。 一、建新表的方式 createtabletarget_tablenametablespacetarget_tablespace_namenologging pctfree10pctused60 storage(initial5Mnext5Mmin

如果你要把ORACLE里的大量数据(80M以上)转移到另外的用户,另外的表空间里。可以用下面介绍的快速转移
数据的方法。
一、建新表的方式

create table target_tablename tablespace target_tablespace_name nologging 
pctfree 10 pctused 60 
storage(initial 5M next 5M minextents 1 maxextents unlimited pctincrease 0)
as select * from username.source_tablename where 条件;

注意事项: 新建的表没有原来表的索引和默认值, 
只有非空(not null)的约束素条件可以继承过来,
其它的约束条件或索引需要重新建立.

二、直接插入的方法

INSERT /*+ APPEND */ INTO target_tablename 
SELECT * FROM username.source_tablename where 条件; 
COMMIT; 

注意事项:
用INSERT /*+ APPEND */ 的方法会对target_tablename产生级别为6的独占锁,
如果运行此命令时还有对target_tablename的DML操作会排队在它后面,
对OLTP系统在用的表操作是不合适的。
说明:这两种方法转移数据时没有用SGA里数据缓冲区和事物处理的回滚段, 也不写联机事物日志,
就象装载工具SQLLOAD一样直接把数据写到物理文件,速度是很快的。

在ORACLE8I以后的版本都可以使用.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:10046event 漫步Next article:SQL Server各种日期计算方法