This page shows how to create, modify, and delete users in an ApsaraDB RDS for SQL Server instance using T-SQL.
Note
Create users only in user databases. Creating users in system databases is not supported.
Prerequisites
Before you begin, ensure that you have:
An RDS instance running SQL Server 2012 or later
A login that has been used to log on to the target database
Create a user
Switch to the target database, then create a user and associate it with a login.
USE [TestDB]; -- Switch to the database TestDB
GO
CREATE USER [TestUser] FOR LOGIN [TestLogin]; -- Create a user named TestUser for the login TestLogin in TestDBModify a user
Use ALTER USER to remap a user to a different login.
USE [TestDB]; -- Switch to the database TestDB
GO
ALTER USER [TestUser] WITH LOGIN = [NewLogin]; -- Change the login of TestUser to NewLoginDelete a user
USE [TestDB]; -- Switch to the database TestDB
GO
DROP USER [TestUser]; -- Delete TestUser