How to rename a database (Not the instance) in mssql

0

I'm just trying to rename a created database on a 2019 MS SQL running on RDS. I have a database named mydb that for multi-tenant purposes, I need to rename to mydb2 as a workaround for hardcoded values in the app. However, in SSMS, when i try to rename the database, I get this error:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Unable to rename mydb2. (ObjectExplorer)

------------------------------
ADDITIONAL INFORMATION:

Rename failed for Database 'mydb'.  (Microsoft.SqlServer.Smo)

For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=16.100.47021.0&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Rename+Database&LinkId=20476

------------------------------

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

User does not have permission to alter database 'mydb', the database does not exist, or the database is not in a state that allows access checks. (Microsoft SQL Server, Error: 5011)

For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver-5011-database-engine-error

------------------------------
BUTTONS:

OK
------------------------------

An using for forceful ways like changing the db to single-access, then altering the db doesn't work either because the error says my admin user doesn't have permissions to change that on a table.

Is the background user rdsadmin logged in and preventing me from changing this? Could I restart the service and close any zombie connections? Maybe I make a copy of the database and give it another name? These seems like overkill but I'm not sure what permissions on RDS are preventing me.

已提問 2 年前檢視次數 870 次
2 個答案
1
已接受的答案

Hello - Thank You for reaching out to us via re:Post - The way to rename a database is a bit different than the native set up in AWS RDS - here you go - please follow the link below https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.SQLServer.CommonDBATasks.RenamingDB.html

AWS
專家
已回答 2 年前
profile picture
專家
已審閱 6 天前
0

Error when trying to run the statements

Msg 50000, Level 16, State 2, Procedure rdsadmin.dbo.rds_modify_db_name, Line 117
The database could not be exclusively locked to perform the operation.
ITW
已回答 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南