How do you rename a database in SQL Server?

In SQL Server, you can use the following command to rename a database:

ALTER DATABASE [原数据库名] MODIFY NAME = [新数据库名];

For example, to rename a database called “old_db” to “new_db”, you can use the following command:

ALTER DATABASE old_db MODIFY NAME = new_db;

Please note that executing this command requires sufficient permissions.

bannerAds