I want to duplicate a very large table, but I do not want to copy it row by row. Is there a way to duplicate it?
For example, you can TRUNCATE w/o deleting row/row, so i was wondering if there is something similar for copying entire tables
UPDATE: row by row insert is very painful (because of 120M rows). Anyway to avoid that?
MySQL no longer has a reliable "copy table" functionality - many reasons for this related to how data is stored. However, the below does row-by-row insertion but is pretty simple:
CREATE TABLE `new_table` LIKE `old_table`;
INSERT INTO `new_table` (SELECT * FROM `old_table`);
You could use INSERT INTO ... SELECT
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With