GRANT (Schema)
Grants schema privileges to users and roles.
Note: By default, new users cannot access schema PUBLIC. You must explicitly grant all new users USAGE privileges on the PUBLIC schema.
Syntax
GRANT { privilege[,…] | ALL [ PRIVILEGES ] } ON SCHEMA [database.]schema[,…] TO grantee[,…] [ WITH GRANT OPTION ]
Parameters
privilege |
One of the following privileges:
The following privileges are automatically granted on new tables and views if inherited privileges are already enabled for the database and this schema:
|
ALL [PRIVILEGES]
|
Grants The optional keyword |
[database.]schema
|
Specifies a target schema. If you specify a database, it must be the current database. |
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. For details, see How to Grant Privileges in the Administrator's Guide. |
Privileges
One of the following:
- Superuser
- Privileges grantee who was given the option (
WITH GRANT OPTION
) of extending these privileges to other users
Examples
This example shows how to grant user Joe usage on schema online_sales
.
=> CREATE USER Joe; CREATE USER
=> GRANT USAGE ON SCHEMA online_sales TO Joe; GRANT PRIVILEGE