Change the database name

xiaoxiao2021-03-06  45

Rename the database needs to use the system stored procedure sp_renamedb, its syntax is as follows:

sp_renamedb [@old_name =] 'OLD_NAME', [@new_name =] 'new_name'

Example 6-12: Change the name of the MYDB database to "My DB".

Exec sp_renamedb 'mydb', 'my db'

The result of the operation is as follows

The Database Name 'My DB' HAS BEEN SET.

Note: Before using this command, you should set the access options for the renamed database to Single User Mode, and turn off the database. After changing the database name, you are still the original database name in Enterprise Manager, only the "DatabaseE" directory folder, then click the "Refresh" button in the toolbar, refresh the interface or restart in SQL Server I will see the changed database name. It should be that it should be that the database is not case sensitive.

转载请注明原文地址:https://www.9cbs.com/read-81246.html

New Post(0)