pub enum Statement {
Show 57 variants
Analyze {
table_name: ObjectName,
partitions: Option<Vec<Expr>>,
for_columns: bool,
columns: Vec<Located<Ident>>,
cache_metadata: bool,
noscan: bool,
compute_statistics: bool,
},
Truncate {
table_name: ObjectName,
partitions: Option<Vec<Expr>>,
},
Msck {
table_name: ObjectName,
repair: bool,
partition_action: Option<AddDropSync>,
},
Query(Box<Query>),
Insert {
or: Option<SqliteOnConflict>,
into: bool,
table_name: ObjectName,
columns: Vec<Located<Ident>>,
overwrite: bool,
source: Box<Query>,
partitioned: Option<Vec<Expr>>,
after_columns: Vec<Located<Ident>>,
table: bool,
on: Option<OnInsert>,
returning: Option<Vec<SelectItem>>,
},
Directory {
overwrite: bool,
local: bool,
path: String,
file_format: Option<FileFormat>,
source: Box<Query>,
},
Copy {
table_name: ObjectName,
columns: Vec<Located<Ident>>,
to: bool,
target: CopyTarget,
options: Vec<CopyOption>,
legacy_options: Vec<CopyLegacyOption>,
values: Vec<Option<String>>,
},
Close {
cursor: CloseCursor,
},
Update {
table: TableWithJoins,
assignments: Vec<Assignment>,
from: Option<TableWithJoins>,
selection: Option<Expr>,
returning: Option<Vec<SelectItem>>,
},
Delete {
table_name: TableFactor,
using: Option<TableFactor>,
selection: Option<Expr>,
returning: Option<Vec<SelectItem>>,
},
CreateView {
or_replace: bool,
materialized: bool,
name: ObjectName,
columns: Vec<Located<Ident>>,
query: Box<Query>,
with_options: Vec<SqlOption>,
cluster_by: Vec<Located<Ident>>,
},
CreateTable {Show 23 fields
or_replace: bool,
temporary: bool,
external: bool,
global: Option<bool>,
if_not_exists: 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>,
default_charset: Option<String>,
collation: Option<String>,
on_commit: Option<OnCommit>,
on_cluster: Option<String>,
},
CreateVirtualTable {
name: ObjectName,
if_not_exists: bool,
module_name: Located<Ident>,
module_args: Vec<Located<Ident>>,
},
CreateIndex {
name: ObjectName,
table_name: ObjectName,
using: Option<Located<Ident>>,
columns: Vec<OrderByExpr>,
unique: bool,
if_not_exists: bool,
},
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<Located<Ident>>,
in_group: Vec<Located<Ident>>,
role: Vec<Located<Ident>>,
user: Vec<Located<Ident>>,
admin: Vec<Located<Ident>>,
authorization_owner: Option<ObjectName>,
},
AlterTable {
name: ObjectName,
operation: AlterTableOperation,
},
AlterIndex {
name: ObjectName,
operation: AlterIndexOperation,
},
Drop {
object_type: ObjectType,
if_exists: bool,
names: Vec<ObjectName>,
cascade: bool,
restrict: bool,
purge: bool,
},
DropFunction {
if_exists: bool,
func_desc: Vec<DropFunctionDesc>,
option: Option<ReferentialAction>,
},
Declare {
name: Located<Ident>,
binary: bool,
sensitive: Option<bool>,
scroll: Option<bool>,
hold: Option<bool>,
query: Box<Query>,
},
Fetch {
name: Located<Ident>,
direction: FetchDirection,
into: Option<ObjectName>,
},
Discard {
object_type: DiscardObject,
},
SetRole {
context_modifier: ContextModifier,
role_name: Option<Located<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<Located<Ident>>,
},
ShowVariables {
filter: Option<ShowStatementFilter>,
},
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<Located<Ident>>,
filter: Option<ShowStatementFilter>,
},
ShowCollation {
filter: Option<ShowStatementFilter>,
},
Use {
db_name: Located<Ident>,
},
StartTransaction {
modes: Vec<TransactionMode>,
},
SetTransaction {
modes: Vec<TransactionMode>,
snapshot: Option<Value>,
session: bool,
},
Comment {
object_type: CommentObject,
object_name: ObjectName,
comment: Option<String>,
},
Commit {
chain: bool,
},
Rollback {
chain: bool,
},
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,
},
Assert {
condition: Expr,
message: Option<Expr>,
},
Grant {
privileges: Privileges,
objects: GrantObjects,
grantees: Vec<Located<Ident>>,
with_grant_option: bool,
granted_by: Option<Located<Ident>>,
},
Revoke {
privileges: Privileges,
objects: GrantObjects,
grantees: Vec<Located<Ident>>,
granted_by: Option<Located<Ident>>,
cascade: bool,
},
Deallocate {
name: Located<Ident>,
prepare: bool,
},
Execute {
name: Located<Ident>,
parameters: Vec<Expr>,
},
Prepare {
name: Located<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: Located<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>,
},
}
Expand description
A top-level statement (SELECT, INSERT, CREATE, etc.)
Variants§
Analyze
Fields
table_name: ObjectName
Analyze (Hive)
Truncate
Truncate (Hive)
Msck
Msck (Hive)
Query(Box<Query>)
SELECT
Insert
Fields
or: Option<SqliteOnConflict>
Only for Sqlite
table_name: ObjectName
TABLE
returning: Option<Vec<SelectItem>>
RETURNING
INSERT
Directory
Copy
Fields
table_name: ObjectName
TABLE
target: CopyTarget
The source of ‘COPY FROM’, or the target of ‘COPY TO’
options: Vec<CopyOption>
WITH options (from PostgreSQL version 9.0)
legacy_options: Vec<CopyLegacyOption>
WITH options (before PostgreSQL version 9.0)
Close
Fields
cursor: CloseCursor
Cursor name
Close - closes the portal underlying an open cursor.
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
UPDATE
Delete
Fields
table_name: TableFactor
FROM
using: Option<TableFactor>
USING (Snowflake, Postgres)
returning: Option<Vec<SelectItem>>
RETURNING
DELETE
CreateView
Fields
name: ObjectName
View name
CREATE VIEW
CreateTable
Fields
name: ObjectName
Table name
constraints: Vec<TableConstraint>
hive_distribution: HiveDistributionStyle
hive_formats: Option<HiveFormat>
file_format: Option<FileFormat>
like: Option<ObjectName>
clone: Option<ObjectName>
on_cluster: Option<String>
Click house “ON CLUSTER” clause: https://clickhouse.com/docs/en/sql-reference/distributed-ddl/
CREATE TABLE
CreateVirtualTable
Fields
name: ObjectName
SQLite’s CREATE VIRTUAL TABLE .. USING <module_name> (<module_args>)
CreateIndex
CREATE INDEX
CreateRole
CREATE ROLE See postgres
AlterTable
ALTER TABLE
AlterIndex
Drop
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.
DROP
DropFunction
Fields
func_desc: Vec<DropFunctionDesc>
One or more function to drop
option: Option<ReferentialAction>
CASCADE
or RESTRICT
DROP Function
Declare
Fields
DECLARE - Declaring Cursor Variables
Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
Fetch
Fields
direction: FetchDirection
into: Option<ObjectName>
Optional, It’s possible to fetch rows form cursor to the table
FETCH - retrieve rows from a query using a cursor
Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
Discard
Fields
object_type: DiscardObject
DISCARD [ ALL | PLANS | SEQUENCES | TEMPORARY | TEMP ]
Note: this is a PostgreSQL-specific statement, but may also compatible with other SQL.
SetRole
Fields
context_modifier: ContextModifier
Non-ANSI optional identifier to inform if the role is defined inside the current session (SESSION
) or transaction (LOCAL
).
SET [ SESSION | LOCAL ]
ROLE role_name. Examples: ANSI, Postgresql, MySQL, and Oracle.
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
Fields
SET NAMES DEFAULT
Note: this is a MySQL-specific statement.
ShowFunctions
Fields
filter: Option<ShowStatementFilter>
SHOW FUNCTIONS
Note: this is a Presto-specific statement.
ShowVariable
SHOW <variable>
Note: this is a PostgreSQL-specific statement.
ShowVariables
Fields
filter: Option<ShowStatementFilter>
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
Fields
filter: Option<ShowStatementFilter>
SHOW TABLES
Note: this is a MySQL-specific statement.
ShowCollation
Fields
filter: Option<ShowStatementFilter>
SHOW COLLATION
Note: this is a MySQL-specific statement.
Use
USE
Note: This is a MySQL-specific statement.
StartTransaction
Fields
modes: Vec<TransactionMode>
{ BEGIN [ TRANSACTION | WORK ] | START TRANSACTION } ...
SetTransaction
SET TRANSACTION ...
Comment
COMMENT ON ...
Note: this is a PostgreSQL-specific statement.
Commit
COMMIT [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]
Rollback
ROLLBACK [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]
CreateSchema
Fields
schema_name: SchemaName
<schema name> | AUTHORIZATION <schema authorization identifier> | <schema name> AUTHORIZATION <schema authorization identifier>
CREATE SCHEMA
CreateDatabase
Fields
db_name: ObjectName
CREATE DATABASE
CreateFunction
Fields
name: ObjectName
args: Option<Vec<OperateFunctionArg>>
params: CreateFunctionBody
Optional parameters.
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 [, ...] ) ]
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
Fields
table_name: ObjectName
Table name
EXPLAIN TABLE Note: this is a MySQL-specific statement. See https://dev.mysql.com/doc/refman/8.0/en/explain.html
Explain
Fields
format: Option<AnalyzeFormat>
Optional output format of explain
EXPLAIN / DESCRIBE for select_statement
Savepoint
SAVEPOINT – define a new savepoint within the current transaction
Merge
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
CreateSequence – define a new sequence CREATE [ { TEMPORARY | TEMP } ] SEQUENCE [ IF NOT EXISTS ] <sequence_name>
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<Statement> for Statement
impl PartialEq<Statement> for Statement
source§impl PartialOrd<Statement> for Statement
impl PartialOrd<Statement> 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 more