使用oracle sql developer从一个数据库复制到另一个数据库-连接失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24458616/
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
copy from one database to another using oracle sql developer - connection failed
提问by user2133404
I am trying to copy a table from one database to another using oracle sql developer. I have the username, password and SIDs.
我正在尝试使用 oracle sql developer 将表从一个数据库复制到另一个数据库。我有用户名、密码和 SID。
copy from uname1/password1@SID1 to uname2/pwd2@SID2 insert table1 (*) using (select * from message_table);
However I am getting the connection failed
error.
但是我收到connection failed
错误。
The two databases are present in different host hosts (the hostname is different in connection properties).
这两个数据库存在于不同的主机中(连接属性中的主机名不同)。
The table has 5 million records and is too cumbersome to export/import
表有500万条记录,导出/导入太麻烦
回答by Patrick Bacon
The copy
command is a SQL*Plus command (not a SQL Developer command). If you have your tnsname entries setup for SID1 and SID2 (e.g. try a tnsping), you should be able to execute your command.
该copy
命令是 SQL*Plus 命令(不是 SQL Developer 命令)。如果您为 SID1 和 SID2 设置了 tnsname 条目(例如尝试 tnsping),您应该能够执行您的命令。
Another assumption is that table1 has the same columns as the message_table (and the columns have only the following data types: CHAR, DATE, LONG, NUMBER or VARCHAR2). Also, with an insert command, you would need to be concerned about primary keys (e.g. that you are not inserting duplicate records).
另一个假设是 table1 与 message_table 具有相同的列(并且这些列只有以下数据类型:CHAR、DATE、LONG、NUMBER 或 VARCHAR2)。此外,使用插入命令,您需要关注主键(例如,您没有插入重复记录)。
I tried a variation of your command as follows in SQL*Plus (with no errors):
我在 SQL*Plus 中尝试了如下命令的变体(没有错误):
copy from scott/tiger@db1 to scott/tiger@db2 create new_emp using select * from emp;
After I executed the above statement, I also truncate the new_emp table and executed this command:
执行完上面的语句后,我还截断了new_emp表并执行了这个命令:
copy from scott/tiger@db1 to scott/tiger@db2 insert new_emp using select * from emp;
With SQL Developer, you could do the following to perform a similar approach to copying objects:
使用 SQL Developer,您可以执行以下操作来执行复制对象的类似方法:
On the tool bar, select Tools>Database copy.
Identify source and destination connections with the copy options you would like.
For object type, select table(s).
- Specify the specific table(s) (e.g. table1).
在工具栏上,选择工具>数据库复制。
使用您想要的复制选项识别源和目标连接。
对于对象类型,选择表格。
- 指定特定的表(例如 table1)。
The copy command approach is old and its features are not being updated with the release of new data types. There are a number of more current approaches to this like Oracle's data pump (even for tables).
复制命令方法很旧,其功能不会随着新数据类型的发布而更新。有许多更当前的方法,例如 Oracle 的数据泵(甚至对于表)。