I need to copy three tables and rename them in the same MySQL database. Does anyone know a statement I can execute, or do I need to export and import?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Answer is here on StackOverflow, hidden under a database rename operation (databases can be renamed by creating a new database, then “moving” the tables).
https://stackoverflow.com/a/2298602/584490
RENAME TABLE db.table TO db.table;From the comments: “I’ve just done this with an InnoDB database with 30+ tables, using the file_per_table setting, and even though some tables were 3+ million rows, it completed in < 1 second. It just seems to move the files on the storage, rather than doing anything more complicated… +2 if possible :)”.