Duplicating a table in MYSQL without copying one row at a time

I want to duplicate a very large table, but I do not want to copy it row by row. Is there any way to duplicate it?

For example, you can TRUNCATE without deleting a row / row, so I was wondering if there was something like this for copying entire tables

UPDATE: inserting line by line is very painful (due to 120M lines). Anyway, to avoid this?

+5
source share
6 answers

MySQL no longer has the robust "copy table" feature - many reasons for this are related to how the data is stored. However, the following inserts row by row, but is pretty simple:

CREATE TABLE `new_table` LIKE `old_table`;
INSERT INTO `new_table` (SELECT * FROM `old_table`);
+5

MyISAM, . , .

+2
INSERT INTO TABLE2 SELECT * FROM TABLE1
+1

; , , , .

InnoDB , , ... , , 120M , , , , , .

mysqldump, , , mysqldump . .

+1

:

Create table t as select * from original_table

0
source

All Articles