Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to copy table contained from one database and insert onto another database table

People also ask

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

Right-click on the database name, then select "Tasks" > "Export data..." from the object explorer. The SQL Server Import/Export wizard opens; click on "Next". Provide authentication and select the source from which you want to copy the data; click "Next". Specify where to copy the data to; click on "Next".

How do I copy an entire table into another table?

The SQL INSERT INTO SELECT Statement The INSERT INTO SELECT statement copies data from one table and inserts it into another table. The INSERT INTO SELECT statement requires that the data types in source and target tables match. Note: The existing records in the target table are unaffected.


If you want to copy a table from one Database to another database , You can simply do as below.

CREATE TABLE db2.table LIKE db1.table;
INSERT INTO db2.table SELECT * FROM db1.table;

or just CREATE TABLE db2.table SELECT * FROM db1.table in MySQL 5


In BASH you can do:

mysqldump database_1 table | mysql database_2

CREATE TABLE db2.table_new AS SELECT * FROM db1.table_old