Tag Archives: MySQL

Copy an existing MySQL table

Occasionally, it’s helpful to run complex queries against the data but you would prefer not run a risk of doing a mass update against live data. Maybe you would just like to create a backup. Either way, it’s really easy to replicate existing data.

You simply need to execute two commands.

CREATE TABLE products_new LIKE production.products; INSERT products_new SELECT * FROM production.products;

That’s all there is to it. It’s pretty fast too. I’ve been able to copy large tables with lots of fields in a matter of minutes.