3. Statements : OpenROAD SQL Statements : Create View Statement : With Check Option Clause
 
Share this page                  
With Check Option Clause
The with check option clause prevents you from executing an insert or update to a view that creates a row that does not comply with the view definition (the qualification specified in the where clause).
For example, if the following view is defined with check option:
create view myview
    as select *
    from mytable
    where mycolumn = 10
    with check option;
And the following update is attempted:
update myview set mycolumn = 5;
The update to the mycolumn column is rolled back, because the updated rows fail the mycolumn = 10 qualification specified in the view definition. If the with check option is omitted, any row in the view can be updated, even if the update results in a row that is no longer a part of the view.
The with check option is valid only for updatable views. The with check option clause cannot be specified if the underlying base table is used in a subselect in the select statement that defines the view. You cannot update or insert into a view defined on top of a view specified with with check option if the resulting rows violate the qualification of the underlying view.