GRANT (database)
Grants database privileges to users and roles.
Grants database privileges to users and roles.
Syntax
GRANT { privilege[,...] | ALL [ PRIVILEGES ] }
ON DATABASE db-spec
TO grantee[,...]
[ WITH GRANT OPTION ]
Parameters
privilege- The following privileges are valid for a database:
-
CREATE: Create schemas. -
TEMP: Create temporary tables. By default, all users are granted this privilege through theirDEFAULTrole.
-
ALL [PRIVILEGES]- Grants all database privileges that also belong to the grantor. Grantors cannot grant privileges that they themselves lack.
The optional keyword
PRIVILEGESconforms with the SQL standard. db-specSpecifies the current database, set to the database name or
DEFAULT.granteeSpecifies who is granted privileges, one of the following:
WITH GRANT OPTIONGives
granteethe privilege to grant the same privileges to other users or roles, and also revoke them. For details, see Granting privileges.
Privileges
Non-superuser: Privileges grantee given the option (WITH GRANT OPTION) of granting privileges to other users or roles.
Examples
The following example grants user Fred the right to create schemas in the current database.
=> GRANT CREATE ON DATABASE DEFAULT TO Fred;