SQL中copy命令使用

Oracle SQL中可以使用copy命令来进行数据的复制.
只需要知道源端和目标端数据库的sqlplus登陆方式,就可以进行表中数据的复制,相对来说也比较灵活.

如下,我们知道两个数据库的sqlplus登陆方式
sqlplus UATDB7/UATDB7@UAT2
sqlplus charsi/charsi@BMCTST9I

现在我们要将UATDB7/UATDB7@UAT2中一部分all_objects表中的数据insert到charsi/charsi@BMCTST9I数据库中的test_tbl表中.可以使用下面的命令

SQL> copy from UATDB7/UATDB7@UAT2 to charsi/charsi@BMCTST9I insert test_tbl using select * from all_objects where rownum <1001;

Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
1000 rows selected from UATDB7@UAT2.
1000 rows inserted into TEST_TBL.
1000 rows committed into TEST_TBL at charsi@BMCTST9I.

SQL> select count(1) from test_tbl;

COUNT(1)
----------
1000


在执行前,为了保证效率和防止回滚段不足的情况,可以设置copycommit参数,如下:

SQL> set timing on echo on;
SQL> set arraysize 50
SQL>
SQL> set copycommit 100
SQL> copy from UATDB7/UATDB7@UAT2 to charsi/charsi@BMCTST9I insert test_tbl using select * from all_objects where rownum <1001;

Array fetch/bind size is 50. (arraysize is 50)
Will commit after every 100 array binds. (copycommit is 100)
Maximum long size is 80. (long is 80)
1000 rows selected from UATDB7@UAT2.
1000 rows inserted into TEST_TBL.
1000 rows committed into TEST_TBL at charsi@BMCTST9I.

SQL> select count(1) from test_tbl;

COUNT(1)
----------
2000

Elapsed: 00:00:00.00
SQL> rollback;

Rollback complete.

Elapsed: 00:00:00.00
SQL> select count(1) from test_tbl;

COUNT(1)
----------
2000

Elapsed: 00:00:00.00

[@more@]

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

转载于:http://blog.itpub.net/23850820/viewspace-1048563/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值