All Products
Search
Document Center

ApsaraDB RDS:Delete a database

Last Updated:Mar 28, 2026

Delete a database from an ApsaraDB RDS for SQL Server instance using the console or an SQL statement.

Prerequisites

    Before you delete a database, make sure that the database is in the ONLINE state. Run the following query to check:

    SELECT name, state_desc FROM sys.databases WHERE name = 'Database name';

    If state_desc returns OFFLINE, bring the database online first:

    EXEC sp_rds_set_db_online 'Database name'

    For details, see Stored procedures.

    Delete a database using the console

    1. Go to the Instances page. In the top navigation bar, select the region where your RDS instance resides, then find the RDS instance and click the instance ID.

    2. In the left-side navigation pane, click Databases.

    3. Find the database and click Delete in the Actions column.

    4. In the confirmation dialog, click OK.

    Delete a database using an SQL statement

    1. Connect to the RDS instance. For details, see Connect to an ApsaraDB RDS for SQL Server instance.

    2. Run the following statement:

      -- Replace database_name with the name of the database to delete
      DROP DATABASE [database_name];

      If DROP DATABASE returns an error on an instance running SQL Server 2012 or later on RDS High-availability Edition, use the following stored procedure instead. It deletes the database, removes associated images, and closes all active connections.

      EXEC sp_rds_drop_database 'database name'

    API reference

    OperationDescription
    DeleteDatabaseDeletes a database.