Concept Flow - Updatable views and limitations
Create View
Query View
Check if View is Updatable
Reflect Changes in View
This flow shows how an update on a view is checked for updatability and either applied to the base table or rejected.
CREATE VIEW v_emp AS SELECT emp_id, emp_name FROM employees; UPDATE v_emp SET emp_name = 'Anna' WHERE emp_id = 2;
| Step | Action | Check/Condition | Result | Effect |
|---|---|---|---|---|
| 1 | Create view v_emp | View definition simple select from one table | View created | View ready for queries |
| 2 | Update v_emp set emp_name='Anna' where emp_id=2 | Is view updatable? (simple select, no joins, no aggregates) | Yes | Proceed to update base table |
| 3 | Apply update to employees table | Row with emp_id=2 exists? | Yes | emp_name changed to 'Anna' in employees |
| 4 | Reflect update in view | View reads updated base table | Updated row visible in view | View shows emp_name='Anna' for emp_id=2 |
| 5 | Try update on non-updatable view | View has join or aggregate | No | Update rejected with error |
| Variable | Start | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|
| emp_name for emp_id=2 | 'John' | Attempt to update to 'Anna' | 'Anna' | 'Anna' | 'Anna' |
Updatable views allow changes through the view to affect base tables. Views are updatable if based on a single table without joins, aggregates, or distinct. Updates on non-updatable views cause errors. Check view definition before updating. Changes reflect in base tables and then in the view.