Alex Rivera | Logout

SQL Command for copying table

Asked 2008-09-25T07:00:17.540
9

What is the SQL command to copy a table from one database to another database? I am using MySQL and I have two databases x and y. Suppose I have a table in x called a and I need to copy that table to y database. Sorry if the question is too novice.

Thanks.

Edit
Report

1 Answer

7

If your two database are separated, the simplest thing to do would be to create a dump of your table and to load it into the second database. Refer to your database manual to see how a dump can be performed.

Otherwise you can use the following syntax (for MySQL)

INSERT INTO database_b.table (SELECT * FROM database_a.table)
answered 2008-09-25T07:13:02.953

Your Answer