This topic describes how to use SQL statements to create and manage users on an ApsaraDB RDS for SQL Server instance.
Note
You can create users only in the databases that you created but not in system databases.
Prerequisites
The RDS instance runs SQL Server 2012 or later.
A login is created and is used to log on to the database in which you want to create a user.
Create a user
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 the user information
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