RefLib

Reference library for AI

Back

postgresql_16:7.1.95.2 Parameters

PostgreSQL 16 > Reference > SQL Commands > CREATE VIEW > Parameters

TEMPORARY or TEMP

If specified, the view is created as a temporary view. Temporary views are automatically dropped at the end of the current session. Existing permanent relations with the same name are not visible to the current session while the temporary view exists, unless they are referenced with schema-qualified names.

If any of the tables referenced by the view are temporary, the view is created as a temporary view (whether TEMPORARY is specified or not).

RECURSIVE

Creates a recursive view. The syntax CREATE RECURSIVE VIEW [ *schema* . ] *view_name* (*column_names*) AS SELECT *...*; is equivalent to CREATE VIEW [ *schema* . ] *view_name* AS WITH RECURSIVE *view_name* (*column_names*) AS (SELECT *...*) SELECT *column_names* FROM *view_name*; A view column name list must be specified for a recursive view.

*name*

The name (optionally schema-qualified) of a view to be created.

*column_name*

An optional list of names to be used for columns of the view. If not given, the column names are deduced from the query.

**WITH ( *view_option_name* [= *view_option_value*] [, ... ] )**

This clause specifies optional parameters for a view; the following parameters are supported: check_option (enum) This parameter may be either local or cascaded, and is equivalent to specifying WITH [ CASCADED | LOCAL ] CHECK OPTION (see below). security_barrier (boolean) This should be used if the view is intended to provide row-level security. See (see postgresql_16:6.4.5) for full details. security_invoker (boolean) This option causes the underlying base relations to be checked against the privileges of the user of the view rather than the view owner. See the notes below for full details. All of the above options can be changed on existing views using ALTER VIEW (see postgresql_16:7.1.43).

*query*

A SELECT (see postgresql_16:7.1.170) or VALUES (see postgresql_16:7.1.183) command which will provide the columns and rows of the view.

WITH [ CASCADED | LOCAL ] CHECK OPTION

This option controls the behavior of automatically updatable views. When this option is specified, INSERT and UPDATE commands on the view will be checked to ensure that new rows satisfy the view-defining condition (that is, the new rows are checked to ensure that they are visible through the view). If they are not, the update will be rejected. If the CHECK OPTION is not specified, INSERT and UPDATE commands on the view are allowed to create rows that are not visible through the view. The following check options are supported: LOCAL New rows are only checked against the conditions defined directly in the view itself. Any conditions defined on underlying base views are not checked (unless they also specify the CHECK OPTION). CASCADED New rows are checked against the conditions of the view and all underlying base views. If the CHECK OPTION is specified, and neither LOCAL nor CASCADED is specified, then CASCADED is assumed.

The CHECK OPTION may not be used with RECURSIVE views.

Note that the CHECK OPTION is only supported on views that are automatically updatable, and do not have INSTEAD OF triggers or INSTEAD rules. If an automatically updatable view is defined on top of a base view that has INSTEAD OF triggers, then the LOCAL CHECK OPTION may be used to check the conditions on the automatically updatable view, but the conditions on the base view with INSTEAD OF triggers will not be checked (a cascaded check option will not cascade down to a trigger-updatable view, and any check options defined directly on a trigger-updatable view will be ignored). If the view or any of its base relations has an INSTEAD rule that causes the INSERT or UPDATE command to be rewritten, then all check options will be ignored in the rewritten query, including any checks from automatically updatable views defined on top of the relation with the INSTEAD rule.

Back