SQL Syntax Reference : CREATE USER
 
CREATE USER
The CREATE USER statement creates a new user account in a database.
This function can be used to create a user account in a database with a password, without a password, or as member of a group.
Syntax
CREATE USER user-name [ WITH PASSWORD user-password ][ IN GROUP referencing-alias ]
Remarks
Note This statement creates a user with the same rights as those of a user created using the PSQL Control Center (PCC). For example, the created user is not restricted by default from creating a database even if the user is not logged in as Master.
Only the Master user can execute this statement.
Security must be turned on to perform this statement.
User-name and user-password here only refer to PSQL databases and are not related to user names and passwords set at the operating system level. PSQL user names, groups, and passwords can also be configured through the PSQL Control Center (PCC).
User name must be unique in the dictionary.
The user name and password must be enclosed in double quotes if they contain spaces or other nonalphanumeric characters.
If you create a user as the member of a group, you must set up the group before creating the user.
For further general information about users and groups, see Master User and Users and Groups in Advanced Operations Guide, and Assigning Permissions Tasks in PSQL User's Guide.
Examples
The following examples show how to create a new user account without any login privileges and without a membership in any group.
CREATE USER pgranger
The new user name is pgranger. The user password is NULL and the user account is not a member of any group.
CREATE USER "polly granger"
The new user name is polly granger with nonalphanumeric characters. The user password is NULL and the user account is not a member of any group.
============ 
The following examples show how to create a new user account with login privileges that is not a member of any group.
CREATE USER pgranger WITH PASSWORD Prvsve1
The new user name is pgranger. The user password is Prsve1 (case-sensitive).
CREATE USER pgranger WITH PASSWORD "Nonalfa$"
The new user name is pgranger. The user password is Nonalfa$ (case-sensitive) with nonalphanumeric characters.
============ 
The following example shows how create a new user as a member of a group without login privileges.
CREATE USER pgranger IN GROUP developers
The new user name is pgranger. The new user account is a assigned to the group developers.
============ 
The following example shows how create a new user as a member of a group with login privileges.
CREATE USER pgranger WITH PASSWORD Prvsve1 IN GROUP developers
The new user name is pgranger. The new user account is assigned to the group developers and has the case-sensitive password Prvsve1. The order of this syntax (CREATE USER..WITH PASSWORD...IN GROUP) is absolutely necessary.
See Also
ALTER USER, DROP USER, GRANT