Skip to content

CREATE USER

Create a database user (or role) and define access privileges for the user.

CREATE USER and CREATE ROLE are synonymous, except for one difference in behavior. When you use CREATE USER, LOGIN is assumed by default. NOLOGIN is assumed when you use CREATE ROLE.

CREATE USER name [ [ WITH ] option [ ... ] ]

where option can be:

     SUPERUSER | NOSUPERUSER
   | CREATEDB | NOCREATEDB
   | CREATEROLE | NOCREATEROLE
   | INHERIT | NOINHERIT
   | LOGIN | NOLOGIN
   | CONNECTION LIMIT connlimit
   | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
   | VALID UNTIL 'timestamp'
   | IN ROLE role_name [, ...]
   | ROLE role_name [, ...]
   | ADMIN role_name [, ...]
   | USER role_name [, ...]

For details about the syntax and examples, see CREATE ROLE.

Parent topic:SQL Commands