Practical Web Programming

Tuesday, April 09, 2013

Backup table data including indexes with SQL

Here's a short and sweet way to backup table data including all the indexes using simple SQL syntaxes.

Create an exact copy of the table you want to backup:

CREATE TABLE new_table_name LIKE old_table_name;

Copy the data from the old table to the new one:

INSERT new_table_name SELECT * FROM old_table_name;


Recent Post