SQL RENAME Database

With RENAME statement you can rename a table.

Some of the relational database management system (RDBMS) does not support this command, because this is not standardizing statement.

SQL RENAME DATABASE statement is used to change the name of a database.


Let's see how to rename MySql and SQL Server databases.

Rename MySQL database

To rename the mysql database, you need to follow the following syntax:

RENAME DATABASE old_db_name TO new_db_name;

Rename SQL server database

This command is useful for SQL server 2005, 2008, 2008R2 .

ALTER DATABASE old_name MODIFY NAME = new_name

If you are using SQL server 2000, you can also use this command to rename the database. But, Microsoft phased out it.

EXEC sp_renamedb 'old_name' , 'new_name'