In MySQL, how to copy the content of one table to another table within the same database?

后端 未结 8 1288
既然无缘
既然无缘 2020-12-22 16:40

I am new to MySQL. I would like to copy the content of one table to another table within the same database. Basically, I would like to insert to a table from another table.

8条回答
  •  借酒劲吻你
    2020-12-22 17:07

    If table1 is large and you don't want to lock it for the duration of the copy process, you can do a dump-and-load instead:

    CREATE TABLE table2 LIKE table1;
    
    SELECT * INTO OUTFILE '/tmp/table1.txt' FROM table1;
    LOAD DATA INFILE '/tmp/table1.txt' INTO TABLE table2;
    

提交回复
热议问题