How copy data from one database to another on different server?

元气小坏坏 提交于 2019-12-02 09:57:41

问题


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:


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


来源:https://stackoverflow.com/questions/13595333/how-copy-data-from-one-database-to-another-on-different-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!