MySQL: How to clone a table
Published:
Ever wanted to, for some reason, clone a database table? Don't really want to export anything or figure out what statement was used to create that table? Turns out that's a lot easier to do than I thought it was.
Stumbled over a blog post on how you can copy a MySQL table with schema and keys, and boy was it easy.
CREATE TABLE newtable LIKE oldtable;
And that's it! Want the data copied over as well?
INSERT INTO newtable SELECT * FROM oldtable;
Super easy! 🙃