Name
RENAME DATABASE
Synopsis
RENAME {DATABASE|SCHEMA} database TO database[,...]Use this statement to rename a given database to a new name,
given after the TO keyword. While a database is being renamed, no other client can
interact with the database involved. Tables that are currently locked
or tables that are part of a transaction in progress cannot be
renamed. Additional databases may be renamed in the same statement,
given in a comma-separated list. This statement was added in version
5.1.7 of MySQL. As of version 5.0.2 of MySQL, the keyword
DATABASE is synonymous with
SCHEMA:
RENAME DATABASE personnel TO human_resources, applicants TO human_resources_applicants;
In this example, the name of the database called
personnel is changed to human_resources, and
applicants is changed to
human_resources_applicants, to coincide with a
renaming of the department to which they relate. All of the tables and
data are the same and continue to exist in the directories with the
new database names.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access