copy to支持parallel

以前经常用copy to在不同数据库之间进行数据的复制, 用了挺方便的。常用的那些功能就不多说了,什么create/replace, arraysize, copycommit, long 这些大家都知道。
今天一个同事复制一个比较大的表的时候,突然问到,copy to 支持并发吗?以前还真没这么用过,因为原来用copy to很少用到比较大的表。
首先google了一下,没有找到太明确的答案。然后再翻下官方文档,官方文档上也没有提到并发。
官方文档只是提了一句,using字句可以使用任何形式的select查询
The USING clause specifies a query that names the source table and specifies the data that COPY copies to the destination table. You can use any form. of the SQL SELECT command to select the data that the COPY command copies.

ok,既然官方文档都说了,可以使用任何select查询,那就尝试下。
1. 首先创建临时表:
SQL> CREATE TABLE t1120 AS SELECT a.* FROM dba_objects a, ( SELECT LEVEL from dual CONNECT BY LEVEL <= 10 ) b;
 
Table created
SQL> SELECT COUNT(*) from t1120;
 
  COUNT(*)
----------
    720650
2.  正常使用copy to,没有并发进程
copy from test/abcd1234@vm_tiger to test_so/abcd1234@ncrmdb71 replace t1120 usingg select * from t1120 ;
select count(*) from v$px_session;     --0
在select 查询中加入并发,
copy from test/abcd1234@vm_tiger to test_so/abcd1234@ncrmdb71 replace t1120 usingg select /*+ parallel(a,5) */ * from t1120 a;
然后查询源表所在的库,可以看到并发进程已经起来了。

由于copy的机制,比如运行copy to,在C上运行,从A到B,A中的每条记录都会先传输到C上,然后传输到B。 如果A,B,C之间网络连接够好的话,copy to效率应该是挺不错的。 如果可以绕过C直接在其中A或者B上运行,效果会相当不错。


论坛上看到一段说明,说的是copy to和db link
Do a sqlplus copy from A to B.  What happens is that every row on A will come down the phone line 
to your PC and sent backup the phone line to B.

Do a create table as select when connected to B - the data now goes from A to B directly -- not 
down your phone line.


The sqlplus client can be a bottleneck in a copy.

Also, copy does inserts - -generates undo/redo.  CTAS wont do undo and may not do redo (nologging 
or noarchivelog mode databases for example)

but copy can be very fast/efficient when used machine to machine over a good network. 

If the copy command is executed from a client PC to copy data from remote database DB0 to remote database DB1, the data will be copied from DB0 to the client PC and then to DB1.  For this reason, it is best to use SQL*Plus from either remote host and not require the data to travel through a client machine in order to reach its final destination.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23700752/viewspace-749576/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23700752/viewspace-749576/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值