SQL Rename Database

In this chapter you will learn:
About rename database
Syntax of rename database
Example of rename database

About rename database

If you have created a database and want to change the name of the database then you can rename it but to do this activity you have to use the sp_renamedb command.

There is also another way to rename a database which is as-
i) Select the database you have to rename
ii) Right click on the database and select the option rename
iii) Now write the name you want to change

Syntax of rename database

sp_renamedb 'old_database_name' , 'new_database_name'

Example of rename database

sp_renamedb university, collage


In the given example you will get that the database university has renamed as collage. Screen shot is given for your better guide-


Database university name has changed as collage whcih is give in below screen shot for your better guide-

database name has changed

In this chapter, you have learned about rename database so if you have created a database and want to change its name then you can do with this statement. In the next chapter you will learn about drop database.


Share your thought