How copy data from one database to another on diff

2020-04-21 01:50发布

I have 2 DB with the same schema on different servers. I need to copy data from table T to the same table T in test database in different server and network.

What is the easiest way to do it? I heard that data can be dumped to flat file and than inserted into database. How does it works? Can this be achieved using sqlplus and oracle database?

Thank you!

1条回答
Evening l夕情丶
2楼-- · 2020-04-21 02:19

Use Oracle export to export a whole table to a file, copy the file to serverB and import.

http://www.orafaq.com/wiki/Import_Export_FAQ

You can use rsync to sync an oracle .dbf file or files to another server. This has problems and syncing all files works more reliably.

For groups of records, write a query to build a pipe-delimited (or whatever delimiter suits your data) file with rows you need to move. Copy that file to serverB. Write a control file for sqlldr and use sqlldr to load the rows into the table. sqlldr is part of the oracle installation.

http://www.thegeekstuff.com/2012/06/oracle-sqlldr/

If you have db listeners up on each server and tnsnames knows about both, you can directly:

insert into mytable@remote 
select * from mytable
  where somecolumn=somevalue;

Look at the remote table section:

http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_9014.htm

If this is going to be an ongoing thing, create a db link from instance@serverA to instance@serverB. You can then do anything you have permissions for with data on one instance or the other or both.

http://psoug.org/definition/CREATE_DATABASE_LINK.htm
查看更多
登录 后发表回答