pub enum Statement {
Show 72 variants
Analyze {
table_name: ObjectName,
partitions: Option<Vec<Expr>>,
for_columns: bool,
columns: Vec<Ident>,
cache_metadata: bool,
noscan: bool,
compute_statistics: bool,
},
Truncate {
table_name: ObjectName,
partitions: Option<Vec<Expr>>,
table: bool,
},
Msck {
table_name: ObjectName,
repair: bool,
partition_action: Option<AddDropSync>,
},
Query(Box<Query>),
Insert {Show 17 fields
or: Option<SqliteOnConflict>,
ignore: bool,
into: bool,
table_name: ObjectName,
table_alias: Option<Ident>,
columns: Vec<Ident>,
overwrite: bool,
source: Option<Box<Query>>,
partitioned: Option<Vec<Expr>>,
after_columns: Vec<Ident>,
table: bool,
as_table: Option<ObjectName>,
as_table_after_columns: Vec<Ident>,
on: Option<OnInsert>,
returning: Option<Vec<SelectItem>>,
replace_into: bool,
priority: Option<MysqlInsertPriority>,
},
Directory {
overwrite: bool,
local: bool,
path: String,
file_format: Option<FileFormat>,
source: Box<Query>,
},
Call(Function),
Copy {
source: CopySource,
to: bool,
target: CopyTarget,
options: Vec<CopyOption>,
legacy_options: Vec<CopyLegacyOption>,
values: Vec<Option<String>>,
},
CopyIntoSnowflake {
into: ObjectName,
from_stage: ObjectName,
from_stage_alias: Option<Ident>,
stage_params: StageParamsObject,
from_transformations: Option<Vec<StageLoadSelectItem>>,
files: Option<Vec<String>>,
pattern: Option<String>,
file_format: DataLoadingOptions,
copy_options: DataLoadingOptions,
validation_mode: Option<String>,
},
Close {
cursor: CloseCursor,
},
Update {
table: TableWithJoins,
assignments: Vec<Assignment>,
from: Option<TableWithJoins>,
selection: Option<Expr>,
returning: Option<Vec<SelectItem>>,
},
Delete {
tables: Vec<ObjectName>,
from: Vec<TableWithJoins>,
using: Option<Vec<TableWithJoins>>,
selection: Option<Expr>,
returning: Option<Vec<SelectItem>>,
order_by: Vec<OrderByExpr>,
limit: Option<Expr>,
},
CreateView {
or_replace: bool,
materialized: bool,
name: ObjectName,
columns: Vec<ViewColumnDef>,
query: Box<Query>,
options: CreateTableOptions,
cluster_by: Vec<Ident>,
with_no_schema_binding: bool,
if_not_exists: bool,
temporary: bool,
},
CreateTable {Show 31 fields
or_replace: bool,
temporary: bool,
external: bool,
global: Option<bool>,
if_not_exists: bool,
transient: bool,
name: ObjectName,
columns: Vec<ColumnDef>,
constraints: Vec<TableConstraint>,
hive_distribution: HiveDistributionStyle,
hive_formats: Option<HiveFormat>,
table_properties: Vec<SqlOption>,
with_options: Vec<SqlOption>,
file_format: Option<FileFormat>,
location: Option<String>,
query: Option<Box<Query>>,
without_rowid: bool,
like: Option<ObjectName>,
clone: Option<ObjectName>,
engine: Option<String>,
comment: Option<String>,
auto_increment_offset: Option<u32>,
default_charset: Option<String>,
collation: Option<String>,
on_commit: Option<OnCommit>,
on_cluster: Option<String>,
order_by: Option<Vec<Ident>>,
partition_by: Option<Box<Expr>>,
cluster_by: Option<Vec<Ident>>,
options: Option<Vec<SqlOption>>,
strict: bool,
},
CreateVirtualTable {
name: ObjectName,
if_not_exists: bool,
module_name: Ident,
module_args: Vec<Ident>,
},
CreateIndex {
name: Option<ObjectName>,
table_name: ObjectName,
using: Option<Ident>,
columns: Vec<OrderByExpr>,
unique: bool,
concurrently: bool,
if_not_exists: bool,
include: Vec<Ident>,
nulls_distinct: Option<bool>,
predicate: Option<Expr>,
},
CreateRole {Show 18 fields
names: Vec<ObjectName>,
if_not_exists: bool,
login: Option<bool>,
inherit: Option<bool>,
bypassrls: Option<bool>,
password: Option<Password>,
superuser: Option<bool>,
create_db: Option<bool>,
create_role: Option<bool>,
replication: Option<bool>,
connection_limit: Option<Expr>,
valid_until: Option<Expr>,
in_role: Vec<Ident>,
in_group: Vec<Ident>,
role: Vec<Ident>,
user: Vec<Ident>,
admin: Vec<Ident>,
authorization_owner: Option<ObjectName>,
},
AlterTable {
name: ObjectName,
if_exists: bool,
only: bool,
operations: Vec<AlterTableOperation>,
},
AlterIndex {
name: ObjectName,
operation: AlterIndexOperation,
},
AlterView {
name: ObjectName,
columns: Vec<Ident>,
query: Box<Query>,
with_options: Vec<SqlOption>,
},
AlterRole {
name: Ident,
operation: AlterRoleOperation,
},
AttachDatabase {
schema_name: Ident,
database_file_name: Expr,
database: bool,
},
Drop {
object_type: ObjectType,
if_exists: bool,
names: Vec<ObjectName>,
cascade: bool,
restrict: bool,
purge: bool,
temporary: bool,
},
DropFunction {
if_exists: bool,
func_desc: Vec<DropFunctionDesc>,
option: Option<ReferentialAction>,
},
Declare {
name: Ident,
binary: bool,
sensitive: Option<bool>,
scroll: Option<bool>,
hold: Option<bool>,
query: Box<Query>,
},
CreateExtension {
name: Ident,
if_not_exists: bool,
cascade: bool,
schema: Option<Ident>,
version: Option<Ident>,
},
Fetch {
name: Ident,
direction: FetchDirection,
into: Option<ObjectName>,
},
Flush {
object_type: FlushType,
location: Option<FlushLocation>,
channel: Option<String>,
read_lock: bool,
export: bool,
tables: Vec<ObjectName>,
},
Discard {
object_type: DiscardObject,
},
SetRole {
context_modifier: ContextModifier,
role_name: Option<Ident>,
},
SetVariable {
local: bool,
hivevar: bool,
variable: ObjectName,
value: Vec<Expr>,
},
SetTimeZone {
local: bool,
value: Expr,
},
SetNames {
charset_name: String,
collation_name: Option<String>,
},
SetNamesDefault {},
ShowFunctions {
filter: Option<ShowStatementFilter>,
},
ShowVariable {
variable: Vec<Ident>,
},
ShowVariables {
filter: Option<ShowStatementFilter>,
global: bool,
session: bool,
},
ShowCreate {
obj_type: ShowCreateObject,
obj_name: ObjectName,
},
ShowColumns {
extended: bool,
full: bool,
table_name: ObjectName,
filter: Option<ShowStatementFilter>,
},
ShowTables {
extended: bool,
full: bool,
db_name: Option<Ident>,
filter: Option<ShowStatementFilter>,
},
ShowCollation {
filter: Option<ShowStatementFilter>,
},
Use {
db_name: Ident,
},
StartTransaction {
modes: Vec<TransactionMode>,
begin: bool,
modifier: Option<TransactionModifier>,
},
SetTransaction {
modes: Vec<TransactionMode>,
snapshot: Option<Value>,
session: bool,
},
Comment {
object_type: CommentObject,
object_name: ObjectName,
comment: Option<String>,
if_exists: bool,
},
Commit {
chain: bool,
},
Rollback {
chain: bool,
savepoint: Option<Ident>,
},
CreateSchema {
schema_name: SchemaName,
if_not_exists: bool,
},
CreateDatabase {
db_name: ObjectName,
if_not_exists: bool,
location: Option<String>,
managed_location: Option<String>,
},
CreateFunction {
or_replace: bool,
temporary: bool,
name: ObjectName,
args: Option<Vec<OperateFunctionArg>>,
return_type: Option<DataType>,
params: CreateFunctionBody,
},
CreateProcedure {
or_alter: bool,
name: ObjectName,
params: Option<Vec<ProcedureParam>>,
body: Vec<Statement>,
},
CreateMacro {
or_replace: bool,
temporary: bool,
name: ObjectName,
args: Option<Vec<MacroArg>>,
definition: MacroDefinition,
},
CreateStage {
or_replace: bool,
temporary: bool,
if_not_exists: bool,
name: ObjectName,
stage_params: StageParamsObject,
directory_table_params: DataLoadingOptions,
file_format: DataLoadingOptions,
copy_options: DataLoadingOptions,
comment: Option<String>,
},
Assert {
condition: Expr,
message: Option<Expr>,
},
Grant {
privileges: Privileges,
objects: GrantObjects,
grantees: Vec<Ident>,
with_grant_option: bool,
granted_by: Option<Ident>,
},
Revoke {
privileges: Privileges,
objects: GrantObjects,
grantees: Vec<Ident>,
granted_by: Option<Ident>,
cascade: bool,
},
Deallocate {
name: Ident,
prepare: bool,
},
Execute {
name: Ident,
parameters: Vec<Expr>,
},
Prepare {
name: Ident,
data_types: Vec<DataType>,
statement: Box<Statement>,
},
Kill {
modifier: Option<KillType>,
id: u64,
},
ExplainTable {
describe_alias: bool,
table_name: ObjectName,
},
Explain {
describe_alias: bool,
analyze: bool,
verbose: bool,
statement: Box<Statement>,
format: Option<AnalyzeFormat>,
},
Savepoint {
name: Ident,
},
ReleaseSavepoint {
name: Ident,
},
Merge {
into: bool,
table: TableFactor,
source: TableFactor,
on: Box<Expr>,
clauses: Vec<MergeClause>,
},
Cache {
table_flag: Option<ObjectName>,
table_name: ObjectName,
has_as: bool,
options: Vec<SqlOption>,
query: Option<Query>,
},
UNCache {
table_name: ObjectName,
if_exists: bool,
},
CreateSequence {
temporary: bool,
if_not_exists: bool,
name: ObjectName,
data_type: Option<DataType>,
sequence_options: Vec<SequenceOptions>,
owned_by: Option<ObjectName>,
},
CreateType {
name: ObjectName,
representation: UserDefinedTypeRepresentation,
},
Pragma {
name: ObjectName,
value: Option<Value>,
is_eq: bool,
},
LockTables {
tables: Vec<LockTable>,
},
UnlockTables,
}Expand description
A top-level statement (SELECT, INSERT, CREATE, etc.)
Variants§
Analyze
ANALYZEAnalyze (Hive)
Fields
table_name: ObjectNameTruncate
TRUNCATETruncate (Hive)
Msck
MSCKMsck (Hive)
Query(Box<Query>)
SELECTInsert
INSERTFields
or: Option<SqliteOnConflict>Only for Sqlite
table_name: ObjectNameTABLE
as_table: Option<ObjectName>Only for mysql
returning: Option<Vec<SelectItem>>RETURNING
priority: Option<MysqlInsertPriority>Only for mysql
Directory
Call(Function)
CALL <function>Copy
COPY [TO | FROM] ...Fields
source: CopySourceThe source of ‘COPY TO’, or the target of ‘COPY FROM’
target: CopyTargetThe target of ‘COPY TO’, or the source of ‘COPY FROM’
options: Vec<CopyOption>WITH options (from PostgreSQL version 9.0)
legacy_options: Vec<CopyLegacyOption>WITH options (before PostgreSQL version 9.0)
CopyIntoSnowflake
COPY INTOSee https://docs.snowflake.com/en/sql-reference/sql/copy-into-table Copy Into syntax available for Snowflake is different than the one implemented in Postgres. Although they share common prefix, it is reasonable to implement them in different enums. This can be refactored later once custom dialects are allowed to have custom Statements.
Fields
into: ObjectNamefrom_stage: ObjectNamestage_params: StageParamsObjectfrom_transformations: Option<Vec<StageLoadSelectItem>>file_format: DataLoadingOptionscopy_options: DataLoadingOptionsClose
CLOSECloses the portal underlying an open cursor.
Fields
cursor: CloseCursorCursor name
Update
UPDATEFields
table: TableWithJoinsTABLE
assignments: Vec<Assignment>Column assignments
from: Option<TableWithJoins>Table which provide value to be set
returning: Option<Vec<SelectItem>>RETURNING
Delete
DELETEFields
tables: Vec<ObjectName>Multi tables delete are supported in mysql
from: Vec<TableWithJoins>FROM
using: Option<Vec<TableWithJoins>>USING (Snowflake, Postgres, MySQL)
returning: Option<Vec<SelectItem>>RETURNING
order_by: Vec<OrderByExpr>ORDER BY (MySQL)
CreateView
CREATE VIEWFields
name: ObjectNameView name
columns: Vec<ViewColumnDef>options: CreateTableOptionswith_no_schema_binding: boolif true, has RedShift [WITH NO SCHEMA BINDING] clause https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_VIEW.html
if_not_exists: boolif true, has SQLite IF NOT EXISTS clause https://www.sqlite.org/lang_createview.html
temporary: boolif true, has SQLite TEMP or TEMPORARY clause https://www.sqlite.org/lang_createview.html
CreateTable
CREATE TABLEFields
name: ObjectNameTable name
constraints: Vec<TableConstraint>hive_distribution: HiveDistributionStylehive_formats: Option<HiveFormat>file_format: Option<FileFormat>like: Option<ObjectName>clone: Option<ObjectName>on_cluster: Option<String>ClickHouse “ON CLUSTER” clause: https://clickhouse.com/docs/en/sql-reference/distributed-ddl/
order_by: Option<Vec<Ident>>ClickHouse “ORDER BY “ clause. Note that omitted ORDER BY is different than empty (represented as ()), the latter meaning “no sorting”. https://clickhouse.com/docs/en/sql-reference/statements/create/table/
partition_by: Option<Box<Expr>>BigQuery: A partition expression for the table. https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#partition_expression
cluster_by: Option<Vec<Ident>>BigQuery: Table clustering column list. https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#table_option_list
options: Option<Vec<SqlOption>>BigQuery: Table options list. https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#table_option_list
CreateVirtualTable
CREATE VIRTUAL TABLE .. USING <module_name> (<module_args>)`Sqlite specific statement
CreateIndex
`CREATE INDEX`CreateRole
CREATE ROLESee postgres
AlterTable
ALTER TABLEAlterIndex
ALTER INDEXAlterView
ALTER VIEWFields
name: ObjectNameView name
AlterRole
ALTER ROLEAttachDatabase
ATTACH DATABASE 'path/to/file' AS alias(SQLite-specific)
Fields
Drop
DROP [TABLE, VIEW, ...]Fields
object_type: ObjectTypeThe type of the object to drop: TABLE, VIEW, etc.
names: Vec<ObjectName>One or more objects to drop. (ANSI SQL requires exactly one.)
cascade: boolWhether CASCADE was specified. This will be false when
RESTRICT or no drop behavior at all was specified.
restrict: boolWhether RESTRICT was specified. This will be false when
CASCADE or no drop behavior at all was specified.
DropFunction
DROP FUNCTIONFields
func_desc: Vec<DropFunctionDesc>One or more function to drop
option: Option<ReferentialAction>CASCADE or RESTRICT
Declare
DECLAREDeclare Cursor Variables
Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
Fields
CreateExtension
CREATE EXTENSION [ IF NOT EXISTS ] extension_name
[ WITH ] [ SCHEMA schema_name ]
[ VERSION version ]
[ CASCADE ]Note: this is a PostgreSQL-specific statement,
Fetch
FETCHRetrieve rows from a query using a cursor
Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
Fields
direction: FetchDirectioninto: Option<ObjectName>Optional, It’s possible to fetch rows form cursor to the table
Flush
FLUSH [NO_WRITE_TO_BINLOG | LOCAL] flush_option [, flush_option] ... | tables_optionNote: this is a Mysql-specific statement, but may also compatible with other SQL.
Discard
DISCARD [ ALL | PLANS | SEQUENCES | TEMPORARY | TEMP ]Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
Fields
object_type: DiscardObjectSetRole
SET [ SESSION | LOCAL ] ROLE role_nameSets sesssion state. Examples: ANSI, Postgresql, MySQL, and Oracle
Fields
context_modifier: ContextModifierNon-ANSI optional identifier to inform if the role is defined inside the current session (SESSION) or transaction (LOCAL).
SetVariable
SET <variable>Note: this is not a standard SQL statement, but it is supported by at least MySQL and PostgreSQL. Not all MySQL-specific syntatic forms are supported yet.
SetTimeZone
SET TIME ZONE <value>Note: this is a PostgreSQL-specific statements
SET TIME ZONE <value> is an alias for SET timezone TO <value> in PostgreSQL
SetNames
SET NAMES 'charset_name' [COLLATE 'collation_name']Note: this is a MySQL-specific statement.
SetNamesDefault
SET NAMES DEFAULTNote: this is a MySQL-specific statement.
ShowFunctions
SHOW FUNCTIONS
Note: this is a Presto-specific statement.
Fields
filter: Option<ShowStatementFilter>ShowVariable
SHOW <variable>Note: this is a PostgreSQL-specific statement.
ShowVariables
SHOW VARIABLESNote: this is a MySQL-specific statement.
ShowCreate
SHOW CREATE TABLENote: this is a MySQL-specific statement.
ShowColumns
SHOW COLUMNSNote: this is a MySQL-specific statement.
ShowTables
SHOW TABLESNote: this is a MySQL-specific statement.
ShowCollation
SHOW COLLATIONNote: this is a MySQL-specific statement.
Fields
filter: Option<ShowStatementFilter>Use
USENote: This is a MySQL-specific statement.
StartTransaction
START [ TRANSACTION | WORK ] | START TRANSACTION } ...If begin is false.
`BEGIN [ TRANSACTION | WORK ] | START TRANSACTION } ...`If begin is true
SetTransaction
SET TRANSACTION ...Comment
COMMENT ON ...Note: this is a PostgreSQL-specific statement.
Fields
object_type: CommentObjectobject_name: ObjectNameif_exists: boolAn optional IF EXISTS clause. (Non-standard.)
See https://docs.snowflake.com/en/sql-reference/sql/comment
Commit
COMMIT [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]Rollback
ROLLBACK [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ] [ TO [ SAVEPOINT ] savepoint_name ]CreateSchema
CREATE SCHEMAFields
schema_name: SchemaName<schema name> | AUTHORIZATION <schema authorization identifier> | <schema name> AUTHORIZATION <schema authorization identifier>
CreateDatabase
CREATE DATABASEFields
db_name: ObjectNameCreateFunction
Fields
name: ObjectNameargs: Option<Vec<OperateFunctionArg>>params: CreateFunctionBodyOptional parameters.
CreateProcedure
CREATE PROCEDURECreateMacro
CreateStage
CREATE STAGESee https://docs.snowflake.com/en/sql-reference/sql/create-stage
Fields
name: ObjectNamestage_params: StageParamsObjectdirectory_table_params: DataLoadingOptionsfile_format: DataLoadingOptionscopy_options: DataLoadingOptionsAssert
ASSERT <condition> [AS <message>]Grant
GRANT privileges ON objects TO granteesRevoke
REVOKE privileges ON objects FROM granteesDeallocate
DEALLOCATE [ PREPARE ] { name | ALL }Note: this is a PostgreSQL-specific statement.
Execute
EXECUTE name [ ( parameter [, ...] ) ]Note: this is a PostgreSQL-specific statement.
Prepare
PREPARE name [ ( data_type [, ...] ) ] AS statementNote: this is a PostgreSQL-specific statement.
Kill
KILL [CONNECTION | QUERY | MUTATION]See https://clickhouse.com/docs/ru/sql-reference/statements/kill/ See https://dev.mysql.com/doc/refman/8.0/en/kill.html
ExplainTable
EXPLAIN TABLENote: this is a MySQL-specific statement. See https://dev.mysql.com/doc/refman/8.0/en/explain.html
Fields
table_name: ObjectNameTable name
Explain
[EXPLAIN | DESCRIBE <select statement>Fields
format: Option<AnalyzeFormat>Optional output format of explain
Savepoint
SAVEPOINTDefine a new savepoint within the current transaction
ReleaseSavepoint
RELEASE [ SAVEPOINT ] savepoint_nameMerge
MERGE INTO <statement>Based on Snowflake. See https://docs.snowflake.com/en/sql-reference/sql/merge.html
Cache
CACHE [ FLAG ] TABLE <table_name> [ OPTIONS('K1' = 'V1', 'K2' = V2) ] [ AS ] [ <query> ]See Spark SQL docs for more details.
UNCache
UNCACHE TABLE [ IF EXISTS ] <table_name>CreateSequence
CREATE [ { TEMPORARY | TEMP } ] SEQUENCE [ IF NOT EXISTS ] <sequence_name>Define a new sequence:
CreateType
CREATE TYPE <name>Pragma
PRAGMA <schema-name>.<pragma-name> = <pragma-value>LockTables
LOCK TABLES <table_name> [READ [LOCAL] | [LOW_PRIORITY] WRITE]Note: this is a MySQL-specific statement. See https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html
UnlockTables
UNLOCK TABLESNote: this is a MySQL-specific statement. See https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html