Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

13.1.9. RENAME DATABASE Syntax

RENAME {DATABASE | SCHEMA} db_name TO new_db_name;

This statement renames a database. It requires the ALTER and DROP privileges for the database, and the CREATE privilege for the new database. RENAME SCHEMA is a synonym for RENAME DATABASE.

When the server receives this statement, it creates a new database. Then it moves tables and other database objects such as triggers to the new database. It also updates the Db column in the system tables for objects such as stored routines and events. Finally, the server drops the old database.

Note that currently there are these limitations:

  • RENAME DATABASE does not change any account privileges listed in the system tables. This needs to be changed manually.

  • RENAME DATABASE does not migrate any stored routines or events to the new schema name. This means that:

    • For stored routines, it does not change any values in the ROUTINE_SCHEMA column of the INFORMATION_SCHEMA.ROUTINES table, or in the db column of the mysql.proc table.

    • For events, it does not change any values in the EVENT_SCHEMA column of the INFORMATION_SCHEMA.EVENTS table, or in the db column of the mysql.event table.

This statement was added in MySQL 5.1.7.


 
 
  Published under the terms of the GNU General Public License Design by Interspire