Sep 25 2008
how to backup a mysql table
A nice and simple way of backing up a mysql table without renaming / exporting is to create a new table with the same structure and copy across the data for the current table.
This can be done without having to copy and paste the structure of the table.
Simply replace the [NEW_TABLE] and [OLD_TABLE] markers with your new / old table names.
CREATE TABLE [NEW_TABLE] LIKE [OLD_TABLE];
INSERT INTO [NEW_TABLE] SELECT * FROM [OLD_TABLE];
For example.
CREATE TABLE products_backup LIKE products;
INSERT INTO products_backup SELECT * FROM products;
This will create the table and maintain any indexes / keys.
I hope this helps.
