This article describes how to use the sqlplus Copy command to transfer data between two databases.
Dblink is not required, and two databases do not need to communicate directly. Of course, there must be a client segment that can be connected to both databases with sqlplus at the same time.
Question proposal
Someone raised the following question on the Forum:
Assume that two databases are in two different networks, but one client has two NICs that can be connected to the two databases at the same time. If you do not create a transit table on the client, is there a way to copy tables from one database to another.
Answers to questions
You can use the copy command of sqlplus.
The Copy command looks like this:
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
In fact, it should be very clear to write, according to that syntax can be completed.
It is equivalent to extracting data from the from dB to the buffer according to <sel>, and then creating a table (Create) Or re-create a table (Replace), And then put the dataInsertOrAppendInsert to the table of the database.
Note that a higher value is usually set.ArraysizeTo reduce the interaction between sqlplus and dB to achieve better performance.
In addition, you do not need to write a password when writing the database string. sqlplus will prompt you to enter the password later.
A complete example:
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.