How to clone a table structure in MySQL
I have often needed to clone a table without it’s data in MySQL.
Oftentimes this has been because I have a continually growing temporary table and I just need to clear up some disk space. And it’s a lot faster and more guaranteed than trying to delete and optimise the table.
Clone a table structure without it’s data
Let’s say that your table in question is called table1:
If you run the above queries either in quick succession, or altogether in a single statement, you will notice that this is a very fast method even on very big tables.
Another article exists to clone and drop tables over here.