Supported SQL Commands
The following table provides a list of the SQL commands that Drill supports, with their descriptions and example syntax:
Command | Description | Syntax |
---|---|---|
ALTER SESSION | Changes a system setting for the duration of a session. A session ends when you quit the Drill shell. For a list of Drill options and their descriptions, refer to Planning and Execution Options. | ALTER SESSION SET `<option_name>`=<value>; |
ALTER SYSTEM | Permanently changes a system setting. The new settings persist across all sessions. For a list of Drill options and their descriptions, refer to Planning and Execution Options. | ALTER SYSTEM SET `<option_name>`=<value>; |
Creates a new table and populates the new table with rows returned from a SELECT query. Use the CREATE TABLE AS (CTAS) statement in place of INSERT INTO. When you issue the CTAS command, you create a directory that contains parquet or CSV files. Each workspace in a file system has a default file type. You can specify which writer you want Drill to use when creating a table: parquet, CSV, or JSON (as specified with the store.format option). | CREATE TABLE new_table_name AS <query>; | |
CREATE VIEW | Creates a virtual structure for the result set of a stored query.- | CREATE [OR REPLACE] VIEW [workspace.]view_name [ (column_name [, ...]) ] AS <query>; |
DESCRIBE | Returns information about columns in a table or view. | DESCRIBE [workspace.]table_name|view_name |
DROP VIEW | Removes a view. | DROP VIEW [workspace.]view_name ; |
EXPLAIN PLAN FOR | Returns the physical plan for a particular query. | EXPLAIN PLAN FOR <query>; |
EXPLAIN PLAN WITHOUT IMPLEMENTATION FOR | Returns the logical plan for a particular query. | EXPLAIN PLAN WITHOUT IMPLEMENTATION FOR <query>; |
SELECT | Retrieves data from tables and files. | [WITH subquery] |
SHOW DATABASES | Returns a list of available schemas. Equivalent to SHOW SCHEMAS. | SHOW DATABASES; |
SHOW FILES | Returns a list of files in a file system schema. | SHOW FILES IN filesystem.`schema_name`; |
SHOW SCHEMAS | Returns a list of available schemas. Equivalent to SHOW DATABASES. | SHOW SCHEMAS; |
SHOW TABLES | Returns a list of tables and views. | SHOW TABLES; |
USE | Change to a particular schema. When you opt to use a particular schema, Drill issues queries on that schema only. | USE schema_name; |