惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
量子位
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
Y
Y Combinator Blog
L
LangChain Blog
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客

博客园 - highmayor

在ABAP的SQL语句中写Oracle Hints Screen numbers ABAP 培训笔记 part 7 更改选择屏幕的GUI STATUS---RS_SET_SELSCREEN_STATUS 隐藏标准选择屏幕的执行按钮 SAP秀才-FI速成手册 FOR ALL ENTRIES的效率问题 SAP学习笔记(HR Develepment学习笔记1) 程序间的调用 abap技术问题中文 - highmayor - 博客园 函数组的文件结构 闲说继承 oracle中使用SQL递归语句 oracle删除重复行 深度理解按位异或运算符 一个容易忽略的陷阱:修改字符串常量的值 - highmayor - 博客园 Oracle数据库 Exp/Imp工具性能调优 通过JDBC操作ORACLE数据库 算法的时间复杂度(计算实例)
使用sqlplus copy 命令在两个数据库间转移数据
highmayor · 2010-06-07 · via 博客园 - highmayor

本文介绍了如何利用sqlplus copy 命令在两个数据库间转移数据

无需用到dblink, 两个数据库间不需直接通讯,当然,需要有一个client段能同时以sqlplus连接到两个数据库

问题的提出

论坛上有人提出这样的问题:

假设有两个数据库,分别处于两个不同的网但有一个客户机安了两块网卡可以同时连到两个数据库请问如果不通过在客户机上建中转表,有没有办法实现这两个数据库中从某一个往另一个拷表.

问题的解答

可以使用sqlpluscopy命令来达到。

copy的命令的这个样子的:

usage: COPY FROM <db> TO <db> <opt> <table> { (<cols>) } USING <sel> <db> : database string, e.g., scott/tiger@d:chicago-mktg
<opt> : ONE of the keywords: APPEND, CREATE, INSERT or REPLACE
<table>: name of the destination table
<cols> : a comma-separated list of destination column aliases
<sel> : any valid SQL SELECT statement

实际上写的应该很清楚了,按照那样的语法就可以完成了。

它相当于从FROM DB根据<sel>把数据取到缓冲区,再根据<opt> TO DB中创建table(create)或者 重新创建table(replace),然后把数据insert或者append insert TO DBtable中。

Ø 有一点需要注意的,通常会设置高一点的arraysize,以便使sqlplusDB的交互减少,以达到更好的性能。

Ø 另外,在写database string时,可以不必写出密码,sqlplus会稍后会提示你输入密码。

一个完整的例子:

sqlplus /nolog

SQL> set arraysize 5000

SQL> copy from serol/luo@mescp to serol/luo@ractest create test_copy_table using select * from dba_objects;

Array fetch/bind size is 5000. (arraysize is 5000)
Will commit when done. (copycommit is 0)
Maximum long size is 5000. (long is 5000)
SQLRCN in cpytbl failed: -2120
Table TEST_COPY_TABLE created.
12579 rows selected from serol@mescp.
12579 rows inserted into TEST_COPY_TABLE.
12579 rows committed into TEST_COPY_TABLE at serol@ractest.