使用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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:08:10  来源:igfitidea点击:

copy from one database to another using oracle sql developer - connection failed

sqldatabaseoracleoracle11goracle-sqldeveloper

提问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 failederror.

但是我收到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 copycommand 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,您可以执行以下操作来执行复制对象的类似方法:

  1. On the tool bar, select Tools>Database copy.

  2. Identify source and destination connections with the copy options you would like. enter image description here

  3. For object type, select table(s). enter image description here

  4. Specify the specific table(s) (e.g. table1). enter image description here
  1. 在工具栏上,选择工具>数据库复制。

  2. 使用您想要的复制选项识别源和目标连接。 在此处输入图片说明

  3. 对于对象类型,选择表格。 在此处输入图片说明

  4. 指定特定的表(例如 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 的数据泵(甚至对于表)。