QuestionQ194

VerifiedCreating Other Schema Objects

Review this view-creation statement:

CREATE VIEW dept30 AS  
SELECT department_id, employee_id, last_name  
FROM employees  
WHERE department_id = 30  
WITH CHECK OPTION;  

What could cause the following statement to fail?

UPDATE dept30  
SET department_id = 10  
WHERE employee_id = 114;  
Explanation

WITH CHECK OPTION prevents an UPDATE through a view when the resulting row would no longer satisfy the view's defining query. Changing DEPARTMENT_ID from 30 to 10 makes the row fail department_id = 30, so the update is rejected.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!