Synopsis
CREATE USER username [ [ WITH ] option [ ... ] ]
where option can be:
SYSID uid
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
| CREATEDB | NOCREATEDB
| CREATEUSER | NOCREATEUSER
| IN GROUP groupname [, ...]
| VALID UNTIL 'abstime'
Notes
Use ALTER USER to
change the attributes of a user, and DROP USER to remove a user. Use ALTER GROUP to add the
user to groups or remove the user from groups.
PostgreSQL includes a program createuser that has
the same functionality as this command (in fact, it calls this
command) but can be run from the command shell.
Examples
Create a user with no password:
CREATE USER jonathan;
Create a user with a password:
CREATE USER davide WITH PASSWORD 'jw8s0F4';
Create a user with a password, whose account is valid until the end of 2001.
Note that after one second has ticked in 2002, the account is not
valid:
CREATE USER miriam WITH PASSWORD 'jw8s0F4' VALID UNTIL 'Jan 1 2002';
Create an account where the user can create databases:
CREATE USER manuel WITH PASSWORD 'jw8s0F4' CREATEDB;