GRANT (Table)
Grants privileges on a table to a user or role. Optionally grants privileges on all tables within one or more schemas.
Note: Granting privileges on all tables in a schema also includes privileges on all views in the same schema.
Syntax
GRANT { privilege[,... ] | ALL [ PRIVILEGES ] } ... ON { ... [ TABLE ] [[database.]schema.]table [,... ] ... | ALL TABLES IN SCHEMA [database.]schema [,...] } ... TO { username | role | PUBLIC } [,... ] ... [ WITH GRANT OPTION ]
Parameters
privilege |
One of the following privileges: Important: Only SELECT privileges can be granted on system tables.
|
ALL [PRIVILEGES]
|
Grants all table privileges that also belong to the grantor. Grantors cannot grant privileges that they themselves lack. The optional keyword |
[database.]schema
|
Specifies a schema, by default myschema.thisDbObject One exception applies: you can specify system tables without their schema name. If you specify a database, it must be the current database. |
table
|
The table on which to grant the privileges. Note: The table can be a global temporary table, but not a local temporary table. See Creating Temporary Tables in the Administrator's Guide. |
ON ALL TABLES IN SCHEMA
|
Grants privileges on all tables (and by default all views) within one or more schemas to a user and/or role. |
username
|
Grants the privilege to the specified user. |
role
|
Grants the privilege to the specified role. |
PUBLIC
|
Grants the privilege to all users. |
WITH GRANT OPTION
|
Allows the user to grant the same privileges to other users. |
Notes
- The user must also be granted USAGE on the schema that contains the table. See GRANT (Schema).
- To use the DELETE or UPDATE commands with a WHERE Clause, a user must have both SELECT and UPDATE and DELETE privileges on the table.
Examples
Grant user Joe
all privileges on table customer_dimension
:
=> CREATE USER Joe; CREATE USER
=> GRANT ALL PRIVILEGES ON TABLE customer_dimension TO Joe; GRANT PRIVILEGE
Grant user Joe
SELECT privileges on all system tables:
=> GRANT SELECT ON ALL TABLES IN SCHEMA V_MONITOR, V_CATALOG TO Joe; GRANT PRIVILEGE