O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

For example, if you want to rename the audit_log table audit_log_archive_2018, you can execute the following:

mysql> USE prod;Database changedmysql> RENAME TABLE audit_log TO audit_log_archive_2018;Query OK, 0 rows affected (0.07 sec)

If you want to move the table from one database to an other, you can use dot notation to specify the database name. For example, if you want to move the audit_log table from the database named prod to the database named archive, execute the following:

mysql> USE prodReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -Amysql> SHOW TABLES;+------------------------+| Tables_in_prod         |+------------------------+| audit_log_archive_2018 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required