简体   繁体   中英

Copy data from one mysql table to another mysql table of same database

I have around 40 million rows in a MySQL table. I want to copy this table into another table of same database. What is the most efficient way to do this? How much time will it take (approx.)?

Try this

CREATE TABLE new_table LIKE old_table;
INSERT INTO new_table SELECT * FROM old_table;
INSERT INTO table2(column1,column2,....) SELECT column1,column2,... FROM table1;
create table new_table as select * from Old_table;

当您以这种方式复制数据时,如果创建表单独的查询并通过单独的查询约束插入数据,则所有约束也都将复制到新表中,而不会在新表中复制

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM