Home » Database » How to copy the structure of one MySQL table to another without copying data

How to copy the structure of one MySQL table to another without copying data



In MySQL sometimes you have to create a copy of an existing table. For instance, you would like to save some data in a temporary table before finally transferring it to the main table. You basically copy the structure of one table to another. You can create a blank table, and you can even transfer the existing data into the newly created table. In this post, we’ll simply copy the structure of one MySQL table to another. This is how you do it:

create table table2 like table1

A very simple command indeed. It creates a new table, “table2” by copying the structure of “table1”.