602SQL Documentation Index  

CREATE USER Statement

statement_CREATE_USER ::= CREATE [ IF NOT EXISTS ] USER user_name [ PASSWORD ‘password‘ ]

Description

The CREATE USER statement creates a new user of the specified name on the server.

The maximum length of a username is 31 characters. Each user must have a unique name in the schema context. If the specified user name already exists the error sqlstate 40004 (KEY_DUPLICITY) occurs.

A password may be specified for the user in this statement as a character string enclosed in apostrophes. If the password is not specified, then the user is assigned an blank password and is prompted to change the password after the first login.

You can set or change the user password with the Set_password function.

Users can be created by security or configuration administrators or by users that have been granted the privilege to do so by these administrators, else error sqlstate W0129 (NO_RIGHT) occurs

After the user creation it is customary to assign the user to a group (Set_membership function).

WARNING! User with a privilege to create user can have not enought privileges to assign him to a group!

Example:

Create user XUSER with password X, create group XGROUP and assign the user to this group.

CREATE USER xuser PASSWORD 'x';

CREATE GROUP xgroup;
CALL Set_membership('xuser', CATEG_USER, 'xgroup', CATEG_GROUP, TRUE);

See