Function
Adds a user to the current workspace, allowing them to access and operate on resources within the workspace.
Syntax
Parameter Description
| Parameter | Required | Description |
|---|---|---|
IF NOT EXISTS | No | If the user already exists in the workspace, skip the operation without error |
user_name | Yes | User identifier; must be a username already created in the instance user management system |
DEFAULT_VCLUSTER | No | Specifies a default compute cluster for the user. When not specified, the workspace's global default cluster is used |
DEFAULT_SCHEMA | No | Specifies a default Schema for the user. Once set, the user automatically uses this Schema upon login; the USE command can switch to a different Schema during the session. Priority: USE command > default Schema |
COMMENT | No | Adds a note or description for the user |
Usage Examples
-
Add user
uat_testto the workspace, using the global default compute cluster and Schema: -
Add a user while specifying both a default compute cluster and a default Schema:
-
Use
IF NOT EXISTSto avoid errors when the user already exists: -
Add a user with a comment:
Successful execution returns an empty result set; no error message means the operation succeeded.
Notes
- Executing this command requires the
workspace_adminoruser_adminrole. user_namemust be an account that already exists in the instance user management system (not at the workspace level); otherwise, an errorNotFound: user does not existis thrown.- After a user is added to a workspace, they have no data permissions by default. Permissions must be granted via the
GRANTcommand or by assigning roles. - When using
IF NOT EXISTS, if the user already exists, the command silently succeeds without modifying any existing configuration.
