Database / SQLite Interview questions
What is a VIEW in SQLite?
A VIEW is a saved, named query that behaves like a virtual, read-only table — querying
the view runs the underlying query fresh each time, rather than storing its own separate copy of data.
CREATE VIEW adult_person AS SELECT id, name, age FROM person WHERE age >= 18; SELECT * FROM adult_person; -- runs the underlying query each time
Views are useful for encapsulating a commonly-needed, possibly complex query behind a simple name, so
application code (or other queries) can reference adult_person without repeating the full
WHERE condition everywhere it's needed. Since a view has no storage of its own, updating the
underlying tables automatically changes what the view returns the next time it's queried — there's no
separate "refresh" step required.
More Related questions...