Sep 25
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.

February 11th, 2009 at 12:38 am
Nice. Didn't know about LIKE being used for that.
There's also SHOW CREATE TABLE foo; Which is handy.
I also wrote some code to "backup" a table to the necessary SQL statements: http://www.puremango.co.uk/cm_db_sql_106.php
It's not always perfect, but it's proven very useful more than a few times in the past.
By the way, your captcha sucks
July 25th, 2009 at 8:12 am
Thanks, it's very nice code.