pub enum Statement {
Show 81 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(Insert),
Install {
extension_name: Ident,
},
Load {
extension_name: Ident,
},
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(Delete),
CreateView {
or_replace: bool,
materialized: bool,
name: ObjectName,
columns: Vec<ViewColumnDef>,
query: Box<Query>,
options: CreateTableOptions,
cluster_by: Vec<Ident>,
comment: Option<String>,
with_no_schema_binding: bool,
if_not_exists: bool,
temporary: bool,
to: Option<ObjectName>,
},
CreateTable(CreateTable),
CreateVirtualTable {
name: ObjectName,
if_not_exists: bool,
module_name: Ident,
module_args: Vec<Ident>,
},
CreateIndex(CreateIndex),
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>,
},
CreateSecret {
or_replace: bool,
temporary: Option<bool>,
if_not_exists: bool,
name: Option<Ident>,
storage_specifier: Option<Ident>,
secret_type: Ident,
options: Vec<SecretOption>,
},
AlterTable {
name: ObjectName,
if_exists: bool,
only: bool,
operations: Vec<AlterTableOperation>,
location: Option<HiveSetLocation>,
},
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,
},
AttachDuckDBDatabase {
if_not_exists: bool,
database: bool,
database_path: Ident,
database_alias: Option<Ident>,
attach_options: Vec<AttachDuckDBDatabaseOption>,
},
DetachDuckDBDatabase {
if_exists: bool,
database: bool,
database_alias: Ident,
},
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>,
},
DropProcedure {
if_exists: bool,
proc_desc: Vec<DropFunctionDesc>,
option: Option<ReferentialAction>,
},
DropSecret {
if_exists: bool,
temporary: Option<bool>,
name: Ident,
storage_specifier: Option<Ident>,
},
Declare {
stmts: Vec<Declare>,
},
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,
variables: OneOrManyWithParens<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>,
},
ShowStatus {
filter: Option<ShowStatementFilter>,
global: bool,
session: bool,
},
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 {Show 15 fields
or_replace: bool,
temporary: bool,
if_not_exists: bool,
name: ObjectName,
args: Option<Vec<OperateFunctionArg>>,
return_type: Option<DataType>,
function_body: Option<CreateFunctionBody>,
behavior: Option<FunctionBehavior>,
called_on_null: Option<FunctionCalledOnNull>,
parallel: Option<FunctionParallel>,
using: Option<CreateFunctionUsing>,
language: Option<Ident>,
determinism_specifier: Option<FunctionDeterminismSpecifier>,
options: Option<Vec<SqlOption>>,
remote_connection: Option<ObjectName>,
},
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>,
using: Vec<Expr>,
},
Prepare {
name: Ident,
data_types: Vec<DataType>,
statement: Box<Statement>,
},
Kill {
modifier: Option<KillType>,
id: u64,
},
ExplainTable {
describe_alias: DescribeAlias,
hive_format: Option<HiveDescribeFormat>,
table_name: ObjectName,
},
Explain {
describe_alias: DescribeAlias,
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,
Unload {
query: Box<Query>,
to: Ident,
with: Vec<SqlOption>,
},
}
Expand description
A top-level statement (SELECT, INSERT, CREATE, etc.)
Variants§
Analyze
ANALYZE
Analyze (Hive)
Fields
table_name: ObjectName
Truncate
TRUNCATE
Truncate (Hive)
Msck
MSCK
Msck (Hive)
Query(Box<Query>)
SELECT
Insert(Insert)
INSERT
Install
INSTALL
Load
LOAD
Directory
Call(Function)
CALL <function>
Copy
COPY [TO | FROM] ...
Fields
source: CopySource
The source of ‘COPY TO’, or the target of ‘COPY FROM’
target: CopyTarget
The 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 INTO
See 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: ObjectName
from_stage: ObjectName
stage_params: StageParamsObject
from_transformations: Option<Vec<StageLoadSelectItem>>
file_format: DataLoadingOptions
copy_options: DataLoadingOptions
Close
CLOSE
Closes the portal underlying an open cursor.
Fields
cursor: CloseCursor
Cursor name
Update
UPDATE
Fields
table: TableWithJoins
TABLE
assignments: Vec<Assignment>
Column assignments
from: Option<TableWithJoins>
Table which provide value to be set
returning: Option<Vec<SelectItem>>
RETURNING
Delete(Delete)
DELETE
CreateView
CREATE VIEW
Fields
name: ObjectName
View name
columns: Vec<ViewColumnDef>
options: CreateTableOptions
comment: Option<String>
Snowflake: Views can have comments in Snowflake. https://docs.snowflake.com/en/sql-reference/sql/create-view#syntax
with_no_schema_binding: bool
if true, has RedShift [WITH NO SCHEMA BINDING
] clause https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_VIEW.html
if_not_exists: bool
if true, has SQLite IF NOT EXISTS
clause https://www.sqlite.org/lang_createview.html
temporary: bool
if true, has SQLite TEMP
or TEMPORARY
clause https://www.sqlite.org/lang_createview.html
to: Option<ObjectName>
if not None, has Clickhouse TO
clause, specify the table into which to insert results
https://clickhouse.com/docs/en/sql-reference/statements/create/view#materialized-view
CreateTable(CreateTable)
CREATE TABLE
CreateVirtualTable
CREATE VIRTUAL TABLE .. USING <module_name> (<module_args>)`
Sqlite specific statement
CreateIndex(CreateIndex)
`CREATE INDEX`
CreateRole
CREATE ROLE
See postgres
CreateSecret
CREATE SECRET
See duckdb
Fields
options: Vec<SecretOption>
AlterTable
ALTER TABLE
Fields
name: ObjectName
Table name
operations: Vec<AlterTableOperation>
location: Option<HiveSetLocation>
AlterIndex
ALTER INDEX
AlterView
ALTER VIEW
Fields
name: ObjectName
View name
AlterRole
ALTER ROLE
AttachDatabase
ATTACH DATABASE 'path/to/file' AS alias
(SQLite-specific)
Fields
AttachDuckDBDatabase
(DuckDB-specific)
ATTACH 'sqlite_file.db' AS sqlite_db (READ_ONLY, TYPE SQLITE);
Fields
attach_options: Vec<AttachDuckDBDatabaseOption>
DetachDuckDBDatabase
Fields
Drop
DROP [TABLE, VIEW, ...]
Fields
object_type: ObjectType
The type of the object to drop: TABLE, VIEW, etc.
names: Vec<ObjectName>
One or more objects to drop. (ANSI SQL requires exactly one.)
cascade: bool
Whether CASCADE
was specified. This will be false
when
RESTRICT
or no drop behavior at all was specified.
restrict: bool
Whether RESTRICT
was specified. This will be false
when
CASCADE
or no drop behavior at all was specified.
DropFunction
DROP FUNCTION
Fields
func_desc: Vec<DropFunctionDesc>
One or more function to drop
option: Option<ReferentialAction>
CASCADE
or RESTRICT
DropProcedure
DROP PROCEDURE
Fields
proc_desc: Vec<DropFunctionDesc>
One or more function to drop
option: Option<ReferentialAction>
CASCADE
or RESTRICT
DropSecret
DROP SECRET
Declare
DECLARE
Declare Cursor Variables
Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
CreateExtension
CREATE EXTENSION [ IF NOT EXISTS ] extension_name
[ WITH ] [ SCHEMA schema_name ]
[ VERSION version ]
[ CASCADE ]
Note: this is a PostgreSQL-specific statement,
Fetch
FETCH
Retrieve rows from a query using a cursor
Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
Fields
direction: FetchDirection
into: 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_option
Note: 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: DiscardObject
SetRole
SET [ SESSION | LOCAL ] ROLE role_name
Sets session state. Examples: ANSI, Postgresql, MySQL, and Oracle
Fields
context_modifier: ContextModifier
Non-ANSI optional identifier to inform if the role is defined inside the current session (SESSION
) or transaction (LOCAL
).
SetVariable
SET <variable> = expression;
SET (variable[, ...]) = (expression[, ...]);
Note: this is not a standard SQL statement, but it is supported by at least MySQL and PostgreSQL. Not all MySQL-specific syntactic 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 DEFAULT
Note: 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.
ShowStatus
SHOW [GLOBAL | SESSION] STATUS [LIKE 'pattern' | WHERE expr]
Note: this is a MySQL-specific statement.
ShowVariables
SHOW VARIABLES
Note: this is a MySQL-specific statement.
ShowCreate
SHOW CREATE TABLE
Note: this is a MySQL-specific statement.
ShowColumns
SHOW COLUMNS
Note: this is a MySQL-specific statement.
ShowTables
SHOW TABLES
Note: this is a MySQL-specific statement.
ShowCollation
SHOW COLLATION
Note: this is a MySQL-specific statement.
Fields
filter: Option<ShowStatementFilter>
Use
USE
Note: 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: CommentObject
object_name: ObjectName
if_exists: bool
An 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 SCHEMA
Fields
schema_name: SchemaName
<schema name> | AUTHORIZATION <schema authorization identifier> | <schema name> AUTHORIZATION <schema authorization identifier>
CreateDatabase
CREATE DATABASE
Fields
db_name: ObjectName
CreateFunction
Fields
name: ObjectName
args: Option<Vec<OperateFunctionArg>>
function_body: Option<CreateFunctionBody>
The expression that defines the function.
Examples:
AS ((SELECT 1))
AS "console.log();"
behavior: Option<FunctionBehavior>
called_on_null: Option<FunctionCalledOnNull>
CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
parallel: Option<FunctionParallel>
PARALLEL { UNSAFE | RESTRICTED | SAFE }
using: Option<CreateFunctionUsing>
USING … (Hive only)
language: Option<Ident>
Language used in a UDF definition.
Example:
CREATE FUNCTION foo() LANGUAGE js AS "console.log();"
determinism_specifier: Option<FunctionDeterminismSpecifier>
Determinism keyword used for non-sql UDF definitions.
remote_connection: Option<ObjectName>
Connection resource for a remote function.
Example:
CREATE FUNCTION foo()
RETURNS FLOAT64
REMOTE WITH CONNECTION us.myconnection
CreateProcedure
CREATE PROCEDURE
CreateMacro
CreateStage
CREATE STAGE
See https://docs.snowflake.com/en/sql-reference/sql/create-stage
Fields
name: ObjectName
stage_params: StageParamsObject
directory_table_params: DataLoadingOptions
file_format: DataLoadingOptions
copy_options: DataLoadingOptions
Assert
ASSERT <condition> [AS <message>]
Grant
GRANT privileges ON objects TO grantees
Revoke
REVOKE privileges ON objects FROM grantees
Deallocate
DEALLOCATE [ PREPARE ] { name | ALL }
Note: this is a PostgreSQL-specific statement.
Execute
EXECUTE name [ ( parameter [, ...] ) ] [USING <expr>]
Note: this is a PostgreSQL-specific statement.
Prepare
PREPARE name [ ( data_type [, ...] ) ] AS statement
Note: 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 | DESC | DESCRIBE] TABLE
Note: this is a MySQL-specific statement. See https://dev.mysql.com/doc/refman/8.0/en/explain.html
Fields
describe_alias: DescribeAlias
EXPLAIN | DESC | DESCRIBE
hive_format: Option<HiveDescribeFormat>
Hive style FORMATTED | EXTENDED
table_name: ObjectName
Table name
Explain
[EXPLAIN | DESC | DESCRIBE] <statement>
Fields
describe_alias: DescribeAlias
EXPLAIN | DESC | DESCRIBE
format: Option<AnalyzeFormat>
Optional output format of explain
Savepoint
SAVEPOINT
Define a new savepoint within the current transaction
ReleaseSavepoint
RELEASE [ SAVEPOINT ] savepoint_name
Merge
A MERGE
statement.
MERGE INTO <target_table> USING <source> ON <join_expr> { matchedClause | notMatchedClause } [ ... ]
Fields
table: TableFactor
Specifies the table to merge
source: TableFactor
Specifies the table or subquery to join with the target table
clauses: Vec<MergeClause>
Specifies the actions to perform when values match or do not match.
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 TABLES
Note: this is a MySQL-specific statement. See https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html
Unload
UNLOAD(statement) TO <destination> [ WITH options ]
See Redshift https://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html and
Trait Implementations§
source§impl<'de> Deserialize<'de> for Statement
impl<'de> Deserialize<'de> for Statement
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Ord for Statement
impl Ord for Statement
source§impl PartialEq for Statement
impl PartialEq for Statement
source§impl PartialOrd for Statement
impl PartialOrd for Statement
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<Statement> for CreateTableBuilder
impl TryFrom<Statement> for CreateTableBuilder
source§impl VisitMut for Statement
impl VisitMut for Statement
fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>
impl Eq for Statement
impl StructuralPartialEq for Statement
Auto Trait Implementations§
impl Freeze for Statement
impl RefUnwindSafe for Statement
impl Send for Statement
impl Sync for Statement
impl Unpin for Statement
impl UnwindSafe for Statement
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)