CREATE VIEW
Create a named view that encapsulates a SELECT statement.Syntax
Description
A view is a virtual table defined by a SELECT statement. It does not store data on disk — every time you query the view, Turso executes the underlying SELECT. Views simplify complex queries, provide a stable interface over evolving table schemas, and restrict which columns or rows are visible.Parameters
Behavior
- Views are read-only. INSERT, UPDATE, and DELETE on a view are not supported unless an INSTEAD OF trigger is defined on the view.
- The SELECT statement is stored in the
sqlite_schematable and parsed each time the view is referenced. - If a table referenced by the view is dropped or altered in an incompatible way, queries against the view produce an error.
Examples
Simplify a Common Query
Aggregate View
Temporary View for a Session
See Also
- CREATE MATERIALIZED VIEW for views that store precomputed results on disk
- DROP VIEW for removing views
- SELECT for the query syntax used in view definitions
- CREATE TRIGGER for INSTEAD OF triggers that make views writable