Changing Custom Database Names
Scenarios
You can use a stored procedure to change a custom database name.
Prerequisites
- An RDS for SQL Server DB instance has been connected. For details about how to connect to a DB instance, see Connecting to a DB Instance.
- For primary/standby DB instances, you need to run the following command to remove database mirroring between them:
- After the primary database name is changed, the system will automatically establish mirroring relationship.
If you do not remove database mirroring for primary/standby DB instances and attempt to change the primary database name, the system displays the following information:
Database database name is on mirroring_state.
- For a DB instance whose DB engine version is 2017 Enterprise Edition, if the database to be renamed is added to the [AG-RDS-YUN] availability group, you must remove the database from the availability group before renaming it. For details, see Removing a Custom Database from an Availability Group.
Constraints
- System database names cannot be changed. If you attempt to change the name of a system database, the system displays the following information:
Error DBName_Source or DBName_Target. Please can not include in ('msdb','master','model','tempdb','rdsadmin','resource') .
- The new database name must be unique. If the new database name already exists, the system displays the following information:
Database database name already exists. Cannot rename database with the same name.
Procedure
Run the following command to change a custom database name:
exec msdb.dbo.rds_rename_database N'oldname',N'newname';
- oldname indicates the original database name.
- newname indicates the new database name.
For example, to change a database name from ABC to XYZ, run the following command:
exec msdb.dbo.rds_rename_database N'ABC',N'XYZ';
The database name 'XYZ' has been set.
After the database name is changed, the system will automatically perform a full backup.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot