GRANT (Database)
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:
|
ALL [PRIVILEGES]
|
Grants all database privileges that also belong to the grantor. Grantors cannot grant privileges that they themselves lack. The optional keyword |
db‑spec
|
Specifies the current database, set to the database name or |
grantee |
Specifies who is granted privileges, one of the following: |
WITH GRANT OPTION
|
Gives grantee the 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.
Example
The following example grants user Fred the right to create schemas in the current database.
=> GRANT CREATE ON DATABASE DEFAULT TO Fred;