DROP USER (SQL)
Synopsis
DROP USER [IF EXISTS] user-name
Arguments
Argument | Description |
---|---|
IF EXISTS | Optional — Suppresses the error if the command is executed on a nonexistent user. |
user-name | The name of the user to be removed. |
Description
The DROP USER command removes a user account. This user account was created and the user-name specified using CREATE USER. If the specified user-name does not correspond to an existing user account, InterSystems IRIS issues an SQLCODE -118 error. You can determine if a user exists by invoking the $SYSTEM.SQL.Security.UserExists()Opens in a new tab method.
User names are not case-sensitive.
You can also delete a user by using the Management Portal. Select System Administration, Security, Users to list the existing users. On this table of user accounts you can click Delete for the user account you wish to delete.
Privileges
The DROP USER command is a privileged operation. Prior to using DROP USER in embedded SQL, you must be logged in as a user with one of the following:
-
The %Admin_Secure administrative resource with USE permission
-
The %Admin_UserEdit administrative resource with USE permission
-
Full security privileges on the system
If you are not, the DROP USER command results in an SQLCODE -99 error (Privilege Violation).
Use the $SYSTEM.Security.Login()Opens in a new tab method to assign a user with appropriate privileges:
DO $SYSTEM.Security.Login("_SYSTEM","SYS")
&sql( )
You must have the %Service_Login:Use privilege to invoke the $SYSTEM.Security.Login method. For further information, refer to %SYSTEM.SecurityOpens in a new tab in the InterSystems Class Reference.
Examples
You can drop PSMITH by issuing the statement:
DROP USER psmith
See Also
-
SQL statements: CREATE USER, ALTER USER, GRANT, REVOKE, %CHECKPRIV
-
“SQL Users, Roles, and Privileges” chapter of Using InterSystems SQL
-
SQLCODE error messages listed in the InterSystems IRIS Error Reference