Moving tables across databases

You can rename a table by executing the RENAME TABLE statement.

For the following illustrations to work, create sample tables and databases

mysql> CREATE DATABASE prod;mysql> CREATE TABLE prod.audit_log (id int NOT NULL, msg varchar(64));mysql> CREATE DATABASE archive;

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.