mysql copy data in one table to another table, sql statement

 

1. The same table structure table, and in the same database (eg, table1, table2) ( different table structure, too )

Sql: INSERT INTO table1 the SELECT * from table2 (complete copy)

INSERT INTO table1 the SELECT DISTINCT * from table2 (not copy duplicate records )

INSERT INTO table1 the SELECT Top 5 * from table2 (the first five records)

2. Not in the same database (eg, db1 table1, table2 the DB2)

SQL: INSERT INTO db1..table1 the SELECT * from db2..table2 (complete copy)

INSERT INTO db1..table1 the SELECT DISTINCT * from db2table2 (not copy duplicate records)

INSERT into tdb1..able1 select top 5 * from db2table2 ( the first five records)

Guess you like

Origin www.cnblogs.com/mark5/p/11202206.html