Skip to content

Instantly share code, notes, and snippets.

@robozavri
Created January 8, 2019 14:10
Show Gist options
  • Select an option

  • Save robozavri/fe87ee8118e651a7f725188ff87616e8 to your computer and use it in GitHub Desktop.

Select an option

Save robozavri/fe87ee8118e651a7f725188ff87616e8 to your computer and use it in GitHub Desktop.
Duplicating a MySQL table, indexes and data
CREATE TABLE newtable LIKE oldtable;
INSERT newtable SELECT * FROM oldtable;
To copy just structure and data use this one:
CREATE TABLE tbl_new AS SELECT * FROM tbl_old;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment