CREATE USER

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

  1. create_user ::= CREATE USER role_name
  2. [ [ WITH ] role_option [ , ... ] ]
  3. role_option ::= SUPERUSER
  4. | NOSUPERUSER
  5. | CREATEDB
  6. | NOCREATEDB
  7. | CREATEROLE
  8. | NOCREATEROLE
  9. | INHERIT
  10. | NOINHERIT
  11. | LOGIN
  12. | NOLOGIN
  13. | CONNECTION LIMIT connlimit
  14. | [ ENCRYPTED ] PASSWORD ' password '
  15. | PASSWORD NULL
  16. | VALID UNTIL ' timestamp '
  17. | IN ROLE role_name [ , ... ]
  18. | IN GROUP role_name [ , ... ]
  19. | ROLE role_name [ , ... ]
  20. | ADMIN role_name [ , ... ]
  21. | USER role_name [ , ... ]
  22. | SYSID uid

create_user

CREATE USER - 图1

role_option

CREATE USER - 图2

Semantics

See CREATE ROLE for more details.

Examples

  • Create a sample user with password.
  1. yugabyte=# CREATE USER John WITH PASSWORD 'password';
  • Grant John all permissions on the yugabyte database.
  1. yugabyte=# GRANT ALL ON DATABASE yugabyte TO John;
  • Remove John’s permissions from the yugabyte database.
  1. yugabyte=# REVOKE ALL ON DATABASE yugabyte FROM John;

See also