Documentation / Storage Parameters / View options
check_option
check_option
This parameter may be either local or cascaded , and is equivalent to specifying WITH [ CASCADED | LOCAL ] CHECK OPTION (see below).
Reading PostgreSQL 18.6.
Description
This parameter may be either local or cascaded , and is equivalent to specifying WITH [ CASCADED | LOCAL ] CHECK OPTION (see below).
- Applies to
- View options
- Value type
- enum
- Values
- local, cascaded
Usage
WITH (check_option = value)View options
Views do not store query results. Set these security or update semantics with CREATE VIEW WITH or ALTER VIEW.
Write checks
This option controls the behavior of automatically updatable views. When this option is specified, INSERT , UPDATE , and MERGE 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 , UPDATE , and MERGE 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. MERGE is not supported if the view or any of its base relations have rules.
Related entries
Documentation and source
Source build
- Version
- 18.6
- Build
- Local English manual 18.6
- Source fingerprint
eb6c2292fdf28e1b4635ab478eec3919411cdf4a6c07553387870e26201f3744
Related entries
security_barriersecurity_barriersecurity_invokersecurity_invoker
Back to Storage Parameters · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.