Skip to main content

AlterTableOperation

Enum AlterTableOperation 

Source
pub enum AlterTableOperation {
Show 52 variants AddConstraint { constraint: TableConstraint, not_valid: bool, }, AddColumn { column_keyword: bool, if_not_exists: bool, column_def: ColumnDef, column_position: Option<MySQLColumnPosition>, }, AddProjection { if_not_exists: bool, name: Ident, select: ProjectionSelect, }, DropProjection { if_exists: bool, name: Ident, }, MaterializeProjection { if_exists: bool, name: Ident, partition: Option<Ident>, }, ClearProjection { if_exists: bool, name: Ident, partition: Option<Ident>, }, DisableRowLevelSecurity, DisableRule { name: Ident, }, DisableTrigger { name: Ident, }, DropConstraint { if_exists: bool, name: Ident, drop_behavior: Option<DropBehavior>, }, DropColumn { has_column_keyword: bool, column_names: Vec<Ident>, if_exists: bool, drop_behavior: Option<DropBehavior>, }, AttachPartition { partition: Partition, }, DetachPartition { partition: Partition, }, FreezePartition { partition: Partition, with_name: Option<Ident>, }, UnfreezePartition { partition: Partition, with_name: Option<Ident>, }, DropPrimaryKey { drop_behavior: Option<DropBehavior>, }, DropForeignKey { name: Ident, drop_behavior: Option<DropBehavior>, }, DropIndex { name: Ident, }, EnableAlwaysRule { name: Ident, }, EnableAlwaysTrigger { name: Ident, }, EnableReplicaRule { name: Ident, }, EnableReplicaTrigger { name: Ident, }, EnableRowLevelSecurity, ForceRowLevelSecurity, NoForceRowLevelSecurity, EnableRule { name: Ident, }, EnableTrigger { name: Ident, }, RenamePartitions { old_partitions: Vec<Expr>, new_partitions: Vec<Expr>, }, ReplicaIdentity { identity: ReplicaIdentity, }, AddPartitions { if_not_exists: bool, new_partitions: Vec<Partition>, }, DropPartitions { partitions: Vec<Expr>, if_exists: bool, }, RenameColumn { old_column_name: Ident, new_column_name: Ident, }, RenameTable { table_name: RenameTableNameKind, }, ChangeColumn { old_name: Ident, new_name: Ident, data_type: DataType, options: Vec<ColumnOption>, column_position: Option<MySQLColumnPosition>, }, ModifyColumn { col_name: Ident, data_type: DataType, options: Vec<ColumnOption>, column_position: Option<MySQLColumnPosition>, }, RenameConstraint { old_name: Ident, new_name: Ident, }, AlterColumn { column_name: Ident, op: AlterColumnOperation, }, SwapWith { table_name: ObjectName, }, SetTblProperties { table_properties: Vec<SqlOption>, }, OwnerTo { new_owner: Owner, }, ClusterBy { exprs: Vec<Expr>, }, DropClusteringKey, SuspendRecluster, ResumeRecluster, Refresh { subpath: Option<String>, }, Suspend, Resume, Algorithm { equals: bool, algorithm: AlterTableAlgorithm, }, Lock { equals: bool, lock: AlterTableLock, }, AutoIncrement { equals: bool, value: ValueWithSpan, }, ValidateConstraint { name: Ident, }, SetOptionsParens { options: Vec<SqlOption>, },
}
Expand description

An ALTER TABLE (Statement::AlterTable) operation

Variants§

§

AddConstraint

ADD <table_constraint> [NOT VALID]

Fields

§constraint: TableConstraint

The table constraint to add.

§not_valid: bool

Whether the constraint should be marked NOT VALID.

§

AddColumn

ADD [COLUMN] [IF NOT EXISTS] <column_def>

Fields

§column_keyword: bool

[COLUMN].

§if_not_exists: bool

[IF NOT EXISTS]

§column_def: ColumnDef

<column_def>.

§column_position: Option<MySQLColumnPosition>

MySQL ALTER TABLE only [FIRST | AFTER column_name]

§

AddProjection

ADD PROJECTION [IF NOT EXISTS] name ( SELECT <COLUMN LIST EXPR> [GROUP BY] [ORDER BY])

Note: this is a ClickHouse-specific operation. Please refer to ClickHouse

Fields

§if_not_exists: bool

Whether IF NOT EXISTS was specified.

§name: Ident

Name of the projection to add.

§select: ProjectionSelect

The projection’s select clause.

§

DropProjection

DROP PROJECTION [IF EXISTS] name

Note: this is a ClickHouse-specific operation. Please refer to ClickHouse

Fields

§if_exists: bool

Whether IF EXISTS was specified.

§name: Ident

Name of the projection to drop.

§

MaterializeProjection

MATERIALIZE PROJECTION [IF EXISTS] name [IN PARTITION partition_name]

Note: this is a ClickHouse-specific operation. Please refer to ClickHouse

Fields

§if_exists: bool

Whether IF EXISTS was specified.

§name: Ident

Name of the projection to materialize.

§partition: Option<Ident>

Optional partition name to operate on.

§

ClearProjection

CLEAR PROJECTION [IF EXISTS] name [IN PARTITION partition_name]

Note: this is a ClickHouse-specific operation. Please refer to ClickHouse

Fields

§if_exists: bool

Whether IF EXISTS was specified.

§name: Ident

Name of the projection to clear.

§partition: Option<Ident>

Optional partition name to operate on.

§

DisableRowLevelSecurity

DISABLE ROW LEVEL SECURITY

Note: this is a PostgreSQL-specific operation. Please refer to PostgreSQL documentation

§

DisableRule

DISABLE RULE rewrite_rule_name

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the rule to disable.

§

DisableTrigger

DISABLE TRIGGER [ trigger_name | ALL | USER ]

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the trigger to disable (or ALL/USER).

§

DropConstraint

DROP CONSTRAINT [ IF EXISTS ] <name>

Fields

§if_exists: bool

IF EXISTS flag for dropping the constraint.

§name: Ident

Name of the constraint to drop.

§drop_behavior: Option<DropBehavior>

Optional drop behavior (CASCADE/RESTRICT).

§

DropColumn

DROP [ COLUMN ] [ IF EXISTS ] <column_name> [ , <column_name>, ... ] [ CASCADE ]

Fields

§has_column_keyword: bool

Whether the COLUMN keyword was present.

§column_names: Vec<Ident>

Names of columns to drop.

§if_exists: bool

Whether IF EXISTS was specified for the columns.

§drop_behavior: Option<DropBehavior>

Optional drop behavior for the column removal.

§

AttachPartition

ATTACH PART|PARTITION <partition_expr> Note: this is a ClickHouse-specific operation, please refer to ClickHouse

Fields

§partition: Partition

Partition expression to attach.

§

DetachPartition

DETACH PART|PARTITION <partition_expr> Note: this is a ClickHouse-specific operation, please refer to ClickHouse

Fields

§partition: Partition

Partition expression to detach.

§

FreezePartition

FREEZE PARTITION <partition_expr> Note: this is a ClickHouse-specific operation, please refer to ClickHouse

Fields

§partition: Partition

Partition to freeze.

§with_name: Option<Ident>

Optional name for the freeze operation.

§

UnfreezePartition

UNFREEZE PARTITION <partition_expr> Note: this is a ClickHouse-specific operation, please refer to ClickHouse

Fields

§partition: Partition

Partition to unfreeze.

§with_name: Option<Ident>

Optional name associated with the unfreeze operation.

§

DropPrimaryKey

DROP PRIMARY KEY

MySQL Snowflake

Fields

§drop_behavior: Option<DropBehavior>

Optional drop behavior for the primary key (CASCADE/RESTRICT).

§

DropForeignKey

DROP FOREIGN KEY <fk_symbol>

MySQL Snowflake

Fields

§name: Ident

Foreign key symbol/name to drop.

§drop_behavior: Option<DropBehavior>

Optional drop behavior for the foreign key.

§

DropIndex

DROP INDEX <index_name>

Fields

§name: Ident

Name of the index to drop.

§

EnableAlwaysRule

ENABLE ALWAYS RULE rewrite_rule_name

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the rule to enable.

§

EnableAlwaysTrigger

ENABLE ALWAYS TRIGGER trigger_name

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the trigger to enable.

§

EnableReplicaRule

ENABLE REPLICA RULE rewrite_rule_name

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the replica rule to enable.

§

EnableReplicaTrigger

ENABLE REPLICA TRIGGER trigger_name

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the replica trigger to enable.

§

EnableRowLevelSecurity

ENABLE ROW LEVEL SECURITY

Note: this is a PostgreSQL-specific operation. Please refer to PostgreSQL documentation

§

ForceRowLevelSecurity

FORCE ROW LEVEL SECURITY

Note: this is a PostgreSQL-specific operation. Please refer to PostgreSQL documentation

§

NoForceRowLevelSecurity

NO FORCE ROW LEVEL SECURITY

Note: this is a PostgreSQL-specific operation. Please refer to PostgreSQL documentation

§

EnableRule

ENABLE RULE rewrite_rule_name

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the rule to enable.

§

EnableTrigger

ENABLE TRIGGER [ trigger_name | ALL | USER ]

Note: this is a PostgreSQL-specific operation.

Fields

§name: Ident

Name of the trigger to enable (or ALL/USER).

§

RenamePartitions

RENAME TO PARTITION (partition=val)

Fields

§old_partitions: Vec<Expr>

Old partition expressions to be renamed.

§new_partitions: Vec<Expr>

New partition expressions corresponding to the old ones.

§

ReplicaIdentity

REPLICA IDENTITY { DEFAULT | USING INDEX index_name | FULL | NOTHING }

Note: this is a PostgreSQL-specific operation. Please refer to PostgreSQL documentation

Fields

§identity: ReplicaIdentity

Replica identity setting to apply.

§

AddPartitions

Add Partitions

Fields

§if_not_exists: bool

Whether IF NOT EXISTS was present when adding partitions.

§new_partitions: Vec<Partition>

New partitions to add.

§

DropPartitions

DROP PARTITIONS ... / drop partitions from the table.

Fields

§partitions: Vec<Expr>

Partitions to drop (expressions).

§if_exists: bool

Whether IF EXISTS was specified for dropping partitions.

§

RenameColumn

RENAME [ COLUMN ] <old_column_name> TO <new_column_name>

Fields

§old_column_name: Ident

Existing column name to rename.

§new_column_name: Ident

New column name.

§

RenameTable

RENAME TO <table_name>

Fields

§table_name: RenameTableNameKind

The new table name or renaming kind.

§

ChangeColumn

Change an existing column’s name, type, and options.

Fields

§old_name: Ident

Old column name.

§new_name: Ident

New column name.

§data_type: DataType

New data type for the column.

§options: Vec<ColumnOption>

Column options to apply after the change.

§column_position: Option<MySQLColumnPosition>

MySQL-specific column position (FIRST/AFTER).

§

ModifyColumn

Modify an existing column’s type and options.

Fields

§col_name: Ident

Column name to modify.

§data_type: DataType

New data type for the column.

§options: Vec<ColumnOption>

Column options to set.

§column_position: Option<MySQLColumnPosition>

MySQL-specific column position (FIRST/AFTER).

§

RenameConstraint

RENAME CONSTRAINT <old_constraint_name> TO <new_constraint_name>

Note: this is a PostgreSQL-specific operation. Rename a constraint on the table.

Fields

§old_name: Ident

Existing constraint name.

§new_name: Ident

New constraint name.

§

AlterColumn

ALTER [ COLUMN ] Alter a specific column with the provided operation.

Fields

§column_name: Ident

The column to alter.

§op: AlterColumnOperation

Operation to apply to the column.

§

SwapWith

‘SWAP WITH <table_name>’

Note: this is Snowflake specific https://docs.snowflake.com/en/sql-reference/sql/alter-table

Fields

§table_name: ObjectName

Table name to swap with.

§

SetTblProperties

‘SET TBLPROPERTIES ( { property_key [ = ] property_val } [, …] )’

Fields

§table_properties: Vec<SqlOption>

Table properties specified as SQL options.

§

OwnerTo

OWNER TO { <new_owner> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }

Note: this is PostgreSQL-specific https://www.postgresql.org/docs/current/sql-altertable.html

Fields

§new_owner: Owner

The new owner to assign to the table.

§

ClusterBy

Fields

§exprs: Vec<Expr>

Expressions used for clustering the table.

§

DropClusteringKey

Remove the clustering key from the table.

§

SuspendRecluster

Suspend background reclustering operations.

§

ResumeRecluster

Resume background reclustering operations.

§

Refresh

Fields

§subpath: Option<String>

Optional subpath for external table refresh

§

Suspend

SUSPEND

Note: this is Snowflake specific for dynamic tables https://docs.snowflake.com/en/sql-reference/sql/alter-table

§

Resume

RESUME

Note: this is Snowflake specific for dynamic tables https://docs.snowflake.com/en/sql-reference/sql/alter-table

§

Algorithm

ALGORITHM [=] { DEFAULT | INSTANT | INPLACE | COPY }

MySQL-specific table alter algorithm.

Fields

§equals: bool

Whether the = sign was used (ALGORITHM = ...).

§algorithm: AlterTableAlgorithm

The algorithm to use for the alter operation (MySQL-specific).

§

Lock

LOCK [=] { DEFAULT | NONE | SHARED | EXCLUSIVE }

MySQL-specific table alter lock.

Fields

§equals: bool

Whether the = sign was used (LOCK = ...).

§lock: AlterTableLock

The locking behavior to apply (MySQL-specific).

§

AutoIncrement

AUTO_INCREMENT [=] <value>

MySQL-specific table option for raising current auto increment value.

Fields

§equals: bool

Whether the = sign was used (AUTO_INCREMENT = ...).

§value: ValueWithSpan

Value to set for the auto-increment counter.

§

ValidateConstraint

VALIDATE CONSTRAINT <name>

Fields

§name: Ident

Name of the constraint to validate.

§

SetOptionsParens

Arbitrary parenthesized SET options.

Example:

SET (scale_factor = 0.01, threshold = 500)`

PostgreSQL

Fields

§options: Vec<SqlOption>

Parenthesized options supplied to SET (...).

Trait Implementations§

Source§

impl Clone for AlterTableOperation

Source§

fn clone(&self) -> AlterTableOperation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AlterTableOperation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AlterTableOperation

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for AlterTableOperation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for AlterTableOperation

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for AlterTableOperation

Source§

fn cmp(&self, other: &AlterTableOperation) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for AlterTableOperation

Source§

fn eq(&self, other: &AlterTableOperation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for AlterTableOperation

Source§

fn partial_cmp(&self, other: &AlterTableOperation) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for AlterTableOperation

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Spanned for AlterTableOperation

§partial span

Missing spans:

Source§

fn span(&self) -> Span

Return the Span (the minimum and maximum Location) for this AST node, by recursively combining the spans of its children.
Source§

impl Visit for AlterTableOperation

Source§

fn visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break>

Visit this node with the provided Visitor. Read more
Source§

impl VisitMut for AlterTableOperation

Source§

fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>

Mutably visit this node with the provided VisitorMut. Read more
Source§

impl Eq for AlterTableOperation

Source§

impl StructuralPartialEq for AlterTableOperation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,