Enterprise only
A view stores a query, not rows. Reading it runs the query against current
data, so a view is never stale, and never faster than the query it wraps. It
is the counterpart to a materialized view, which
stores rows and is brought up to date by a refresh; both are
catalog objects defined by a query, differing only in when
that query runs.
The SDK methods create_view, describe_view, list_views, and drop_view
submit SQL through the connection’s Flight endpoint. drop_view_async returns
a job of type query whose single id is the SQL query UUID. Waiting confirms
catalog removal; physical cleanup can continue afterward.
CREATE VIEW
name, query, and schema columns.
query contains the stored query, including any declared column aliases, and
schema contains its Arrow schema as JSON. The schema metadata keys
lancedb::view::default_db and lancedb::view::default_namespace identify the
defining database and namespace. The root namespace is public; nested
namespace components are separated by $.
DESCRIBE VIEW "recent_matches" returns the same metadata shape. Anything the
dialect supports can define one: joins, predicates,
aggregates, window functions.
Reading one
A view is queried like a table:DROP VIEW
Listing
namespace_path, a compact JSON array
of parent namespace components ([] for root), and name, the unqualified
object name. Omitting IN lists all authorized namespaces in the current database;
IN team$ml selects that exact path without a database qualifier; IN public selects
the current database’s root. Listings require the relevant database and
namespace USAGE privileges.
Page through results using LIMIT n [FROM '<page-token>']. Read the opaque
lancedb.next_page_token from the Arrow result schema metadata and pass it back
unchanged with the same object type and scope. Stop when no token is returned;
a short or empty page can still carry a continuation. See
catalog listing pagination.
Choosing between a view and a materialized view
Reach for a view when the query is cheap, or when reading stale rows would
be wrong. Reach for a materialized view when the query is expensive and the
data changes less often than it is read.
The privileges are separate too:
CREATE_VIEW and CREATE_MATERIALIZED_VIEW
are distinct grants on a namespace, so the ability to create one does not imply
the other. See Authorization.
What to read next
Materialized View
The stored-rows counterpart.
Management
Where views fit among the other catalog objects.