pub enum AlterTableAction {
Show 31 variants
AddColumn {
column: ColumnDef,
if_not_exists: bool,
position: Option<ColumnPosition>,
},
DropColumn {
name: Identifier,
if_exists: bool,
cascade: bool,
},
RenameColumn {
old_name: Identifier,
new_name: Identifier,
if_exists: bool,
},
AlterColumn {
name: Identifier,
action: AlterColumnAction,
use_modify_keyword: bool,
},
RenameTable(TableRef),
AddConstraint(TableConstraint),
DropConstraint {
name: Identifier,
if_exists: bool,
},
DropForeignKey {
name: Identifier,
},
DropPartition {
partitions: Vec<Vec<(Identifier, Expression)>>,
if_exists: bool,
},
AddPartition {
partition: Expression,
if_not_exists: bool,
location: Option<Expression>,
},
Delete {
where_clause: Expression,
},
SwapWith(TableRef),
SetProperty {
properties: Vec<(String, Expression)>,
},
UnsetProperty {
properties: Vec<String>,
},
ClusterBy {
expressions: Vec<Expression>,
},
SetTag {
expressions: Vec<(String, Expression)>,
},
UnsetTag {
names: Vec<String>,
},
SetOptions {
expressions: Vec<Expression>,
},
AlterIndex {
name: Identifier,
visible: bool,
},
SetAttribute {
attribute: String,
},
SetStageFileFormat {
options: Option<Expression>,
},
SetStageCopyOptions {
options: Option<Expression>,
},
AddColumns {
columns: Vec<ColumnDef>,
cascade: bool,
},
DropColumns {
names: Vec<Identifier>,
},
ChangeColumn {
old_name: Identifier,
new_name: Identifier,
data_type: Option<DataType>,
comment: Option<String>,
cascade: bool,
},
AlterSortKey {
this: Option<String>,
expressions: Vec<Expression>,
compound: bool,
},
AlterDistStyle {
style: String,
distkey: Option<Identifier>,
},
SetTableProperties {
properties: Vec<(Expression, Expression)>,
},
SetLocation {
location: String,
},
SetFileFormat {
format: String,
},
ReplacePartition {
partition: Expression,
source: Option<Box<Expression>>,
},
}Expand description
Actions for ALTER TABLE
Variants§
AddColumn
DropColumn
RenameColumn
AlterColumn
RenameTable(TableRef)
AddConstraint(TableConstraint)
DropConstraint
DropForeignKey
DROP FOREIGN KEY action (Oracle/MySQL): ALTER TABLE t DROP FOREIGN KEY fk_name
Fields
name: IdentifierDropPartition
DROP PARTITION action (Hive/BigQuery)
Fields
partitions: Vec<Vec<(Identifier, Expression)>>List of partitions to drop (each partition is a list of key=value pairs)
AddPartition
ADD PARTITION action (Hive/Spark)
Delete
DELETE action (BigQuery): ALTER TABLE t DELETE WHERE condition
Fields
where_clause: ExpressionSwapWith(TableRef)
SWAP WITH action (Snowflake): ALTER TABLE a SWAP WITH b
SetProperty
SET property action (Snowflake): ALTER TABLE t SET property=value
Fields
properties: Vec<(String, Expression)>UnsetProperty
UNSET property action (Snowflake): ALTER TABLE t UNSET property
ClusterBy
CLUSTER BY action (Snowflake): ALTER TABLE t CLUSTER BY (col1, col2)
Fields
expressions: Vec<Expression>SetTag
SET TAG action (Snowflake): ALTER TABLE t SET TAG key=‘value’
Fields
expressions: Vec<(String, Expression)>UnsetTag
UNSET TAG action (Snowflake): ALTER TABLE t UNSET TAG key1, key2
SetOptions
SET with parenthesized options (TSQL): ALTER TABLE t SET (SYSTEM_VERSIONING=ON, …)
Fields
expressions: Vec<Expression>AlterIndex
ALTER INDEX action (MySQL): ALTER TABLE t ALTER INDEX i VISIBLE/INVISIBLE
SetAttribute
PostgreSQL: ALTER TABLE t SET LOGGED/UNLOGGED/WITHOUT CLUSTER/WITHOUT OIDS/ACCESS METHOD/TABLESPACE
SetStageFileFormat
Snowflake: ALTER TABLE t SET STAGE_FILE_FORMAT = (options)
Fields
options: Option<Expression>SetStageCopyOptions
Snowflake: ALTER TABLE t SET STAGE_COPY_OPTIONS = (options)
Fields
options: Option<Expression>AddColumns
Hive/Spark: ADD COLUMNS (col1 TYPE, col2 TYPE) [CASCADE]
DropColumns
Spark/Databricks: DROP COLUMNS (col1, col2, …)
Fields
names: Vec<Identifier>ChangeColumn
Hive/MySQL/SingleStore: CHANGE [COLUMN] old_name new_name [data_type] [COMMENT ‘comment’] In SingleStore, data_type can be omitted for simple column renames
AlterSortKey
Redshift: ALTER TABLE t ALTER SORTKEY AUTO|NONE|(col1, col2) Also: ALTER TABLE t ALTER COMPOUND SORTKEY (col1, col2)
Fields
expressions: Vec<Expression>Column list for (col1, col2) syntax
AlterDistStyle
Redshift: ALTER TABLE t ALTER DISTSTYLE ALL|EVEN|AUTO|KEY Also: ALTER TABLE t ALTER DISTSTYLE KEY DISTKEY col Also: ALTER TABLE t ALTER DISTKEY col (shorthand for DISTSTYLE KEY DISTKEY col)
Fields
distkey: Option<Identifier>DISTKEY column (only when style is KEY)
SetTableProperties
Redshift: ALTER TABLE t SET TABLE PROPERTIES (‘a’ = ‘5’, ‘b’ = ‘c’)
Fields
properties: Vec<(Expression, Expression)>SetLocation
Redshift: ALTER TABLE t SET LOCATION ‘s3://bucket/folder/’
SetFileFormat
Redshift: ALTER TABLE t SET FILE FORMAT AVRO
ReplacePartition
ClickHouse: ALTER TABLE t REPLACE PARTITION expr FROM source_table
Trait Implementations§
Source§impl Clone for AlterTableAction
impl Clone for AlterTableAction
Source§fn clone(&self) -> AlterTableAction
fn clone(&self) -> AlterTableAction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more