CREATE USER
This page documents the preview version (v2.23). Preview includes features under active development and is for development and testing only. For production, use the stable version (v2024.1). To learn more, see Versioning.
Synopsis
Use the CREATE USER statement to create a user. The CREATE USER statement is an alias for CREATE ROLE, but creates a role that has LOGIN privileges by default.
Syntax
create_user ::= CREATE USER role_name
[ [ WITH ] role_option [ , ... ] ]
role_option ::= SUPERUSER
| NOSUPERUSER
| CREATEDB
| NOCREATEDB
| CREATEROLE
| NOCREATEROLE
| INHERIT
| NOINHERIT
| LOGIN
| NOLOGIN
| CONNECTION LIMIT connlimit
| [ ENCRYPTED ] PASSWORD ' password '
| PASSWORD NULL
| VALID UNTIL ' timestamp '
| IN ROLE role_name [ , ... ]
| IN GROUP role_name [ , ... ]
| ROLE role_name [ , ... ]
| ADMIN role_name [ , ... ]
| USER role_name [ , ... ]
| SYSID uid
Semantics
See CREATE ROLE for more details.
Examples
- Create a sample user with password.
yugabyte=# CREATE USER John WITH PASSWORD 'password';
- Grant John all permissions on the
yugabytedatabase.
yugabyte=# GRANT ALL ON DATABASE yugabyte TO John;
- Remove John's permissions from the
yugabytedatabase.
yugabyte=# REVOKE ALL ON DATABASE yugabyte FROM John;