Delete a database account

Updated at:

Delete standard accounts, privileged accounts, and SA-privileged accounts from an ApsaraDB RDS for SQL Server instance using the ApsaraDB RDS console or the DeleteAccount API operation.

Warning

Deletion is permanent and cannot be undone. Before you delete an account, make sure the account is no longer used by any applications — existing application connections will fail immediately after deletion. Update your application credentials before proceeding.

Prerequisites

Before you begin, ensure that you have:

  • An ApsaraDB RDS for SQL Server instance

  • Access to the ApsaraDB RDS console with sufficient permissions to manage accounts

Account permission rules

Understanding how deletion affects permissions helps you avoid unexpected access issues.

Privileged account rules

Scenario

Behavior

Create a privileged account

Automatically granted the db_owner role for all existing databases. No manual grant needed.

Add a database

The account does not have access to databases created after the account was created. Modify the permission scope in the console to grant db_owner on the new database.

Delete a privileged account

Permanently removes the account and all its database permissions. The account can no longer log on or perform any database operations.

Recreate a privileged account

Regardless of username, the system automatically grants db_owner on all existing databases in the instance. For databases created afterward, modify permissions manually.

Manually selecting the sysadmin server role for a privileged account in SQL Server Management Studio (SSMS) does not take effect. ApsaraDB RDS applies security restrictions to privileged accounts and does not allow you to directly grant the sysadmin permission. If you need the sysadmin permission, create a database account with SA permissions. After you create this type of account, the instance is no longer covered by the SLA.

Standard account rules

Scenario

Behavior

Create a standard account

Manually specify authorized databases and permissions: Read/Write, Read-Only, or Owner. If no database is selected, the account has no access to any database.

Add a database

No access to newly created databases by default, even if the account was previously granted permissions. Manually add the database to the account's authorization list and set permissions.

Delete a standard account

All database access permissions are permanently removed. The account can no longer log on, and connections from attached applications will fail. Update the application credentials promptly.

Recreate a standard account (same name)

Original permissions are not restored. The new account starts with no permissions. Re-authorize databases and set permissions manually.

Global read-only account rules

Scenario

Behavior

Create a global read-only account

When the account is created, it is automatically granted read-only permissions on all existing databases in the instance. No per-database grant is required. The account cannot access the master system database or the rdscore system database, if it exists.

Add a database

The account is automatically granted read-only access to databases created after the account. No manual grant or permission scope change is required.

Delete a global read-only account

Deleting the account permanently removes the account and its read-only permissions. The account can no longer be used to log on or perform database operations.

Re-create a global read-only account

Regardless of whether you use the original account name, the system automatically grants the account read-only permissions on all existing databases in the instance. The account is also automatically granted read-only permissions on databases created afterward, without manual grants.

Delete an account

  1. Go to the Instances page. In the top navigation bar, select the region where the instance resides. Find the instance and click its ID.

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

  3. Find the account you want to delete and click Delete in the Actions column.

  4. In the dialog box, click OK.

References

FAQ

How do I resolve the error "The database principal owns a schema in the database." when I delete an account from an ApsaraDB RDS for SQL Server instance?

Problem description

When I try to delete an account on the Accounts page of an ApsaraDB RDS for SQL Server instance, the following error message is reported:

The database principal owns a schema in the database.

Cause

This error means the account owns one or more schemas. SQL Server blocks deletion of schema owners to maintain schema integrity. Transfer schema ownership to another account before deleting this one.

Solutions

  1. Connect to the instance using SQL Server Management Studio (SSMS).

  2. Transfer schema ownership using one of the following methods:

    • Method 1: View and change the schema owner in the SSMS graphical user interface (GUI)

      In the left-side Object Explorer of SSMS, expand Security > Schemas under the target database, select the target schema (for example, jms01), and right-click to open its properties. In the Schema Properties dialog box, on the General tab, change Schema owner to another user (for example, jmadmin), and then click OK.

    • Method 2: View and change the schema owner using SQL statements

      1. Check which databases contain schemas owned by the target account:

        USE <target_database_name>;
        GO
        SELECT sis.name AS SchemaName, soo.name AS OwnerName
        FROM sys.schemas sis
        JOIN sys.database_principals soo ON sis.principal_id = soo.principal_id
        WHERE soo.name = 'username_to_delete'
      2. Then, transfer ownership of each schema to another account:

        ALTER AUTHORIZATION ON SCHEMA::<target_schema_name> TO <new_owner_username>;
  3. Return to the Accounts page and delete the account.