Created
August 20, 2014 09:36
-
-
Save dnaber-de/f65378d4dc5c9e5ab88d to your computer and use it in GitHub Desktop.
How to copy a table in MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS dbname.new_tablename LIKE dbname.old_tablename; | |
ALTER TABLE dbname.new_tablename DISABLE KEYS; | |
TRUNCATE TABLE dbname.new_tablename; | |
INSERT INTO dbname.new_tablename SELECT * FROM dbname.old_tablename; | |
ALTER TABLE dbname.new_tablename ENABLE KEYS; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment