Renaming SQL database refers to the process of changing the name of an existing database to a new name. "ALTER DATABASE" command is used to change the properties of the database.
Before renaming you should backup the database. It is a good practice to backup the database to ensure that you have a copy of the data in case something goes wrong during the renaming process.
As you can see in below image, [SQL Tutorial] database is present. Let's rename it as [BI Tutorial].
1. Run below SQL command in SSMS :
USE [master]; ALTER DATABASE [SQL Tutorial] MODIFY NAME = [BI Tutorial];
2. Above command will rename [SQL Tutorial] as [BI Tutorial] database.
That's it! You have successfully renamed [SQL Tutorial] as [BI Tutorial] database using T-SQL.
1. Right-click on the database you want to rename in "Database folder" >> Select "Rename".
2. It will let you edit in database name, type the new database name >> Click "Enter".
3. A message will appear asking you to confirm if you really want change the database name >> Select "Yes".
4. There you go, [SQL Tutorial] renamed as [BI Tutorial] database successfully.
That's it! You have successfully renamed [SQL Tutorial] as [BI Tutorial] database using GUI.
To rename an existing SQL database, use the ALTER DATABASE statement followed by the RENAME TO clause.
In SQL Server, you can rename a database filename by detaching the database, renaming the physical files, and then reattaching it with the new file names.
The rename command in SQL typically involves altering the database object's name using the appropriate SQL statement.
The rename command in a database management system allows you to change the name of various database objects such as tables, columns, or indexes.