Relational Database ServiceRelational Database Service

Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Cloud Certificate Manager
Anti-DDoS Service
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain Service
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Cloud Communications
Message & SMS
Cloud Ecosystem
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
Intelligent EdgeFabric
SDK Developer Guide
API Request Signing Guide
Koo Command Line Interface
Updated at: Apr 02, 2022 GMT+08:00

Changing Custom Database Names


You can use a stored procedure to change a custom database name.


  • An RDS Microsoft 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:

    alter database [dbname] set partner off

  • 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.


  • 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.


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';

If the database name is changed, the system displays the following information:
The database name 'XYZ' has been set.

After the database name is changed, the system will automatically perform a full backup.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?

Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel