Question

  Asked: Feb 28 2008   11:41 AM GMT
  Asked by: Lakshmimadhuri


How do I copy a table from one database instance to another database instance?


DBA, Database

How do I copy a table from one database instance to another database instance?

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



we would need to know what type of database you are using before we can answer that with specifics. Are you using Microsoft Access, Microsoft SQL server, MySQL, PostgreSQL, Oracle, etc?

in MySQL it is possible to use the dump command to dump just a table. Research the command on mysql.com

there are some easy commands in MS SQL:

SELECT * INTO NewTable FROM existingdb.dbo.existingtable;

you would need to modify it to suit your DBs. but other databases have similar commands and it all depends on what database you are using and what version it is. Give us some more info and we can help you out. Mrdenny is a DB architect and I am sure he can go into a more in-depth discussion on this issue but he will also need to know the type and version of database you are using.

With Microsoft SQL you can use Data Transformation Services (DTS) to do this for you via a wizard, just be sure and select the source and destination databases as the proper source and destination you need. With other SQL server types the method is similar, basically export it from the source and import that data into the destination table on the new database.

----------------
The SELECT INTO command shouldn't ever be used to move data. It causes locking of system objects which can lead to major performance issues when run against large tables. More info can be found here.

You've got a few options when it comes to importing and exporting data in Microsoft SQL Server.

In SQL 2000 and below you've got DTS which can easily move data from table to table. You've also go the import/export wizard to help you through the process if you aren't used to using DTS.

In SQL 2005 and above DTS was replaced with SSIS. It's a little more complex, but you've still got the import/export wizard to help you through the process.

If you are up to some typing in a DOS prompt, you can use BCP to import and export the data. It's a little less forgiving because it's a command line tool, but once you get the syntax down it's very easy to use, and can be much faster than using DTS or SSIS.

Most every RDBMS will have some sort of import/export tool that can be used to handle this kind of work.
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Database.

Looking for relevant Database Whitepapers? Visit the SearchOracle.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Mrdenny  |   Feb 29 2008  1:50AM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.