Wednesday, March 18, 2009

How to Copy an Existing MySQL Table Into a New Table

Sometimes you might need to duplicate a table for testing purposes. You should never run your testing in a production database.

Here are two simple commands to duplicate a table.

CREATE TABLE test_table LIKE production.table;
INSERT INTO test_table SELECT * FROM production.table;

No comments:

Related Posts Plugin for WordPress, Blogger...