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 Antworten
1
Akzeptierte Antwort

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
EXPERTE
beantwortet vor 2 Jahren
profile picture
EXPERTE
überprüft vor einem Monat
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
beantwortet vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen