SQL language reference
This is a SQL command reference for Databricks SQL and Databricks Runtime.
For information about using SQL with Delta Live Tables, see Delta Live Tables SQL language reference.
Note
Databricks SQL Serverless is not available in Azure operated by 21Vianet.
General reference
This general reference describes data types, functions, identifiers, literals, and semantics:
- "Applies to" label
- How to read a syntax diagram
- How to add comments to SQL statements
- Configuration parameters
- Data types and literals
- Functions
- SQL data type rules
- Datetime patterns
- H3 geospatial functions
- Lambda functions
- Window functions
- Identifiers
- Names
- IDENTIFIER clause
- NULL semantics
- Expressions
- Parameter markers
- Variables
- Name resolution
- JSON path expressions
- Partitions
- ANSI compliance in Databricks Runtime
- Apache Hive compatibility
- Principals
- Privileges and securable objects in Unity Catalog
- Privileges and securable objects in the Hive metastore
- Refresh Unity Catalog metadata
- External locations
- External tables
- Storage credentials
- Volumes
- Delta Sharing
- Federated queries (Lakehouse Federation)
- Information schema
- Reserved words
DDL statements
You use data definition statements to create or modify the structure of database objects in a database:
DML statements
You use data manipulation statements to add, change, or delete data from a Delta Lake table:
- COPY INTO
- DELETE FROM
- INSERT INTO
- INSERT OVERWRITE DIRECTORY
- INSERT OVERWRITE DIRECTORY with Hive format
- LOAD DATA
- MERGE INTO
- UPDATE
Data retrieval statements
You use a query to retrieve rows from one or more tables according to the specified clauses. The full syntax
and brief description of supported clauses are explained in the Query article.
The related SQL statements SELECT
and VALUES
are also included in this section.
Databricks SQL also provides the ability to generate the logical and physical plan for a query using the EXPLAIN
statement.
Delta Lake statements
You use Delta Lake SQL statements to manage tables stored in Delta Lake format:
- CACHE SELECT
- CONVERT TO DELTA
- DESCRIBE HISTORY
- FSCK REPAIR TABLE
- GENERATE
- OPTIMIZE
- REORG TABLE
- RESTORE
- VACUUM
For details on using Delta Lake statements, see What is Delta Lake?.
Auxiliary statements
You use auxiliary statements to collect statistics, manage caching, explore metadata, set configurations, and manage resources:
- Analyze statement
- Apache Spark Cache statements
- Describe statements
- Show statements
- Configuration, variable management, and misc statements
- Resource management
Analyze statement
Apache Spark Cache statements
Applies to: Databricks Runtime
Describe statements
- DESCRIBE CATALOG
- DESCRIBE CONNECTION
- DESCRIBE CREDENTIAL
- DESCRIBE DATABASE
- DESCRIBE FUNCTION
- DESCRIBE LOCATION
- DESCRIBE PROVIDER
- DESCRIBE QUERY
- DESCRIBE RECIPIENT
- DESCRIBE SCHEMA
- DESCRIBE SHARE
- DESCRIBE TABLE
- DESCRIBE VOLUME
Show statements
- LIST
- SHOW ALL IN SHARE
- SHOW CATALOGS
- SHOW COLUMNS
- SHOW CONNECTIONS
- SHOW CREATE TABLE
- SHOW CREDENTIALS
- SHOW DATABASES
- SHOW FUNCTIONS
- SHOW GROUPS
- SHOW LOCATIONS
- SHOW PARTITIONS
- SHOW PROVIDERS
- SHOW RECIPIENTS
- SHOW SCHEMAS
- SHOW SHARES
- SHOW SHARES IN PROVIDER
- SHOW TABLE
- SHOW TABLES
- SHOW TABLES DROPPED
- SHOW TBLPROPERTIES
- SHOW USERS
- SHOW VIEWS
- SHOW VOLUMES
Configuration, variable management, and misc statements
Resource management
Applies to: Databricks Runtime
Applies to: Databricks SQL Connector
Security statements
You use security SQL statements to manage access to data:
- ALTER GROUP
- CREATE GROUP
- DENY
- DROP GROUP
- GRANT
- GRANT SHARE
- REPAIR PRIVILEGES
- REVOKE
- REVOKE SHARE
- SHOW GRANTS
- SHOW GRANTS ON SHARE
- SHOW GRANTS TO RECIPIENT
For details about using these statements, see Hive metastore privileges and securable objects (legacy).