0
0
SQLquery~5 mins

Updatable views and limitations in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an updatable view in SQL?
An updatable view is a virtual table that allows you to insert, update, or delete rows through it, and these changes affect the underlying base tables.
Click to reveal answer
beginner
Name one common limitation of updatable views.
Views that use joins, aggregates, or groupings often cannot be updated because the database cannot clearly map changes back to the original tables.
Click to reveal answer
intermediate
Can you update a view that contains a GROUP BY clause?
No, views with GROUP BY clauses are generally not updatable because the data is aggregated and does not directly map to individual rows in the base tables.
Click to reveal answer
intermediate
What happens if you try to update a view that includes a join of multiple tables?
Most databases do not allow updates on views with joins because it is unclear which base table should be updated, leading to ambiguity.
Click to reveal answer
advanced
How can you make a non-updatable view updatable?
You can create INSTEAD OF triggers on the view to define custom actions for insert, update, or delete operations, making the view behave as updatable.
Click to reveal answer
Which of the following views is usually updatable?
AA view with a GROUP BY clause
BA view with DISTINCT keyword
CA view joining multiple tables
DA view selecting columns from a single table without aggregates
Why are views with joins often not updatable?
ABecause the database cannot decide which base table to update
BBecause they contain too many columns
CBecause they use indexes
DBecause they are read-only by default
What SQL feature can make a non-updatable view behave like an updatable one?
ADISTINCT keyword
BGROUP BY clause
CINSTEAD OF triggers
DIndexes
Can you update a view that uses aggregate functions like SUM or COUNT?
AYes, always
BNo, because aggregates do not map to individual rows
CYes, but only in MySQL
DOnly if the view has a primary key
Which of these is NOT a limitation for updatable views?
ASelecting from a single table
BUsing DISTINCT
CUsing GROUP BY
DUsing joins
Explain what makes a view updatable and list common limitations that prevent a view from being updatable.
Think about how the database knows where to apply changes.
You got /3 concepts.
    Describe how INSTEAD OF triggers can help with updating views that are normally not updatable.
    Triggers act like middlemen for view updates.
    You got /3 concepts.