GRANT (View)

Grants privileges on a view to a database user or role.

Syntax

GRANT ... {  SELECT | ALL [ PRIVILEGES ]}
... ON [ [ db-name.]schema.]viewname [, ...]
... TO { username | role |   PUBLIC } [, ...] 
... [ WITH GRANT OPTION ]

Parameters

SELECT

Grants a user or role SELECT operations to a view and any resources referenced within it.

ALL

Grants a user or role all privileges to a view, and any resources referenced within it.

PRIVILEGES

[Optional] For SQL standard compatibility and is ignored.

[db-name.]schema

Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example:

myschema.thisDbObject
viewname

Specifies the view on which to grant the privileges. When using more than one schema, specify the schema that contains the view, as noted above.

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

Permits the user to grant the same privileges to other users.

Examples

This example shows how to grant user Joe all privileges on view ship.

=> CREATE VIEW ship AS SELECT * FROM public.shipping_dimension;
CREATE VIEW
=> GRANT ALL PRIVILEGES ON ship TO Joe;
GRANT PRIVILEGE

See Also