Skip to content

本页尚未翻译

本页内容仍为英文原文,源自官方文档 sql/index。中文翻译正在分批进行中。

SQL reference ​

SQL statements, expressions and data types supported by LanceDB Enterprise.

LanceDB Enterprise supports SQL through an Arrow Flight SQL endpoint. This reference covers statement syntax, data types and expressions. To set up a client and run your first query, see SQL.

The dialect ​

LanceDB uses Apache DataFusion for SQL planning and execution. These pages describe LanceDB's supported statements and extensions. DataFusion's reference is useful for expression syntax, but does not establish that every DataFusion statement or feature is exposed by LanceDB.

Connecting ​

Use Python's execute_query or a Flight SQL client after configuring the Enterprise connection. TypeScript applications use a Flight SQL client for SQL queries.

python
reader = db.execute_query("SELECT id, text FROM my_docs LIMIT 10")
for batch in reader:
    print(batch)

SQL results arrive as Arrow record batches. Iterating over the reader avoids collecting the entire result in application memory. See Read and manage results for more.

Usage ​

The endpoint executes one statement per request and is meant for the queries and DDL/DML pages below. Reach for the SDKs instead for table-management operations that have no SQL form, such as a merge insert. See What SQL cannot do.

Reference ​

DDL, by object ​

DatabaseCREATE, DESCRIBE, SHOW, ATTACH, DROP DATABASE
NamespaceCREATE, ALTER, DESCRIBE, SHOW, DROP SCHEMA/NAMESPACE
TableCREATE, DESCRIBE, ALTER, CLONE, DROP TABLE
ViewCREATE VIEW, DROP VIEW
Materialized viewCREATE MATERIALIZED VIEW, SHOW MATERIALIZED VIEWS
SecretCREATE, ALTER, DESCRIBE, SHOW, DROP SECRET
Storage IntegrationCREATE, DESCRIBE, SHOW, DROP STORAGE INTEGRATION
IndexCREATE INDEX, DROP INDEX
FunctionCREATE FUNCTION, SHOW FUNCTIONS, DROP FUNCTION
JobSHOW JOBS, SHOW JOB EVENTS, DESCRIBE JOB, SHOW ERRORS, PAUSE/RESUME/CANCEL JOB

DML ​

InsertINSERT INTO, including INSERT ... SELECT
UpdateUPDATE ... SET
DeleteDELETE FROM
CopyCOPY (refused by recent deployment versions)
Refresh columnfilling a computed column
Refresh materialized viewbringing a view's stored result up to date

DQL ​

Data typeshow Lance columns appear to SQL, and pseudo-columns
Selectprojection, filtering, ordering, set operations, CTEs
Subqueriesscalar, IN, EXISTS, correlated, derived tables
Joinsinner, outer, cross, and namespace-qualified paths
AggregationGROUP BY, HAVING, the aggregate set
Window functionsOVER, framing, ranking and offset functions
SamplingTABLESAMPLE, by rows or by fragments
ChangesCHANGES: rows appended since an earlier version
Full-Text Searchthe fts() table function, and its query forms
Operatorscomparison, logical, arithmetic, literals, precedence
Functionswhere to find each kind, and table functions
Scalar functionsthe per-row catalogue, and what Lance accelerates
ExplainEXPLAIN, EXPLAIN ANALYZE, EXPLAIN VERBOSE

SQL limitations and alternatives ​

Vector searchSee SQL vector search for supported query forms and server-version requirements. The SDK query builder also supports vector search.
Merge insertno SQL form: it needs a source relation and a per-match policy
information_schemanot enabled, so SHOW TABLES and SHOW COLUMNS fail
COPYrefused by recent deployment versions (see Copy)
PREPARE / EXECUTEpreparation is a protocol feature, not a statement
Run on a local databaseno engine to plan the statement

See Limits for the bounds these pages enforce.