Project: StarRocks (App Definition and Development / Database)
File: ALTER_TABLE.md

displayed_sidebar: "English" Modifies an existing table, including: :::tip This operation requires the ALTER privilege on the destination table. ::: ```SQL ALTER TABLE [<dbname>.]<tblname> alterclause1[, alterclause2, ...] ``` `alter_clause` can held the following operations: rename, comment, partition, bucket, column, rollup index, bitmap index, table property, swap, and compaction. rename: renames a table, rollup index, or partition. comment: modifies the table comment (supported from v3.1 onwards). partition: modifies partition properties, drops a partition, or adds a partition. bucket: modifies the bucketing method and number of buckets. column: adds, drops, or reorders columns, or modifies column type. rollup index: creates or drops a rollup index. bitmap index: modifies index (only Bitmap index can be modified). swap: atomic exchange of two tables. compaction: performs manual compaction to merge versions of loaded data (supported from v3.1 onwards). Operations on partition, column, and rollup index cannot be performed in one ALTER TABLE statement. Column names cannot be modified. Column comments cannot be modified. One table can have only one ongoing schema change operation at a time. You cannot run two schema change commands on a table at the same time. Operations on bucket, column and rollup index are asynchronous operations. A success message is return immediately after the task is submitted. You can run the command to check the progress, and run the command to cancel the operation. Operations on rename, comment, partition, bitmap index and swap are synchronous operations, and a command return indicates that the execution is finished. Rename supports modification of table name, rollup index, and partition name. ```sql ALTER TABLE <tblname> RENAME <newtbl_name> ``` ```sql ALTER TABLE [<dbname>.]<tblname> RENAME ROLLUP <oldrollupname> <newrollupname> ``` ```sql ALTER TABLE [<dbname>.]<tblname> RENAME PARTITION <oldpartitionname> <newpartitionname> ``` Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> COMMENT = "<new table comment>"; ``` :::tip Currently, column comments cannot be modified. ::: Syntax: ```SQL ALTER TABLE [<dbname>.]<tblname> ADD PARTITION [IF NOT EXISTS] <partition_name> partition_desc ["key"="value"] [DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num]]; ``` Note: Partition_desc supports the following two expressions: ```plain VALUES LESS THAN [MAXVALUE|("value1", ...)] VALUES ("value1", ...), ("value1", ...) ``` partition is the left-closed-right-open interval. If the user only specifies the right boundary, the system will automatically determine the left boundary. If the bucket mode is not specified, the bucket method used by the built-in table is automatically used. If the bucket mode is specified, only the bucket number can be modified, and the bucket mode or bucket column cannot be modified. The user can set some properties of the partition in ` for details. Syntax: ```sql -- Before 2.0 ALTER TABLE [<dbname>.]<tblname> DROP PARTITION [IF EXISTS | FORCE] <partition_name> -- 2.0 or later ALTER TABLE [<dbname>.]<tblname> DROP PARTITION [IF EXISTS] <partition_name> [FORCE] ``` Note: Keep at least one partition for partitioned tables. After executing DROP PARTITION, you can recover the dropped partition by using the command within a specified period (1 day by default). If DROP PARTITION FORCE is executed, the partition will be deleted directly and cannot be recovered without checking whether there are any unfinished activities on the partition. Thus, generally, this operation is not recommended. Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> ADD TEMPORARY PARTITION [IF NOT EXISTS] <partition_name> partition_desc ["key"="value"] [DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num]] ``` Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> REPLACE PARTITION <partition_name> partition_desc ["key"="value"] WITH TEMPORARY PARTITION partition_desc ["key"="value"] [PROPERTIES ("key"="value", ...)] ``` Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> DROP TEMPORARY PARTITION <partition_name> ``` Syntax ```sql ALTER TABLE

MODIFY PARTITION { <partitionname> | ( <partition1name> [, <partition2_name> ...] ) | (*) } SET ("key" = "value", ...); ``` Usages The following properties of a partition can be modified: storage_medium storagecooldownttl or storagecooldowntime replication_num For the table that has only one partition, the partition name is the same as the table name. If the table is divided into multiple partitions, you can use `(*)`to modify the properties of all partitions, which is more convenient. Execute `SHOW PARTITIONS FROM <tbl_name>` to view the partition properties after modification. Syntax: ```SQL ALTER TABLE [<dbname>.]<tablename> [ partition_names ] [ distribution_desc ] partition_names ::= (PARTITION | PARTITIONS) ( <partitionname> [, <partitionname> ...] ) distribution_desc ::= DISTRIBUTED BY RANDOM [ BUCKETS <num> ] | DISTRIBUTED BY HASH ( <columnname> [, <columnname> ...] ) [ BUCKETS <num> ] ``` Example: For example, the original table is a Duplicate Key table where hash bucketing is used and the number of buckets is automatically set by StarRocks. ```SQL CREATE TABLE IF NOT EXISTS details ( event_time DATETIME NOT NULL COMMENT "datetime of event", event_type INT NOT NULL COMMENT "type of event", user_id INT COMMENT "id of user", device_code INT COMMENT "device code", channel INT COMMENT "" ) DUPLICATE KEY(eventtime, eventtype) PARTITION BY datetrunc('day', eventtime) DISTRIBUTED BY HASH(user_id); -- Insert data of several days INSERT INTO details (eventtime, eventtype, userid, devicecode, channel) VALUES -- Data of November 26th ('2023-11-26 08:00:00', 1, 101, 12345, 2), ('2023-11-26 09:15:00', 2, 102, 54321, 3), ('2023-11-26 10:30:00', 1, 103, 98765, 1), -- Data of November 27th ('2023-11-27 08:30:00', 1, 104, 11111, 2), ('2023-11-27 09:45:00', 2, 105, 22222, 3), ('2023-11-27 11:00:00', 1, 106, 33333, 1), -- Data of November 28th ('2023-11-28 08:00:00', 1, 107, 44444, 2), ('2023-11-28 09:15:00', 2, 108, 55555, 3), ('2023-11-28 10:30:00', 1, 109, 66666, 1); ``` NOTICE The modification is applied to all partitions in the table and cannot be applied to specific partitions only. Although only the bucketing method needs to be modified, the number of buckets still needs to be specified in the command using `BUCKETS <num>`. If `BUCKETS <num>` is not specified, it means that the number of buckets is automatically determined by StarRocks. The bucketing method is modified to random bucketing from hash bucketing and the number of buckets remains automatically set by StarRocks. ```SQL ALTER TABLE details DISTRIBUTED BY RANDOM; ``` The keys for hash bucketing are modified to `userid, eventtime` from `eventtime, eventtype`. And the number of buckets remains automatically set by StarRocks. ```SQL ALTER TABLE details DISTRIBUTED BY HASH(userid, eventtime); ``` NOTICE Although only the number of buckets needs to be modified, the bucketing method still needs to be specified in the command, for example, `HASH(user_id)`. Modify the number of buckets for all partitions to 10 from being automatically set by StarRocks. ```SQL ALTER TABLE details DISTRIBUTED BY HASH(user_id) BUCKETS 10; ``` Modify the number of buckets for specified partitions to 15 from being automatically set by StarRocks. ```SQL ALTER TABLE details PARTITIONS (p20231127, p20231128) DISTRIBUTED BY HASH(user_id) BUCKETS 15 ; ``` > NOTE > > Partition names can be viewed by executing `SHOW PARTITIONS FROM <table_name>;`. NOTICE The modification is applied to all partitions in the table and cannot be applied to specific partitions only. Modify the bucketing method from hash bucketing to random bucketing, and change the number of buckets to 10 from being automatically set by

```SQL ALTER TABLE details DISTRIBUTED BY RANDOM BUCKETS 10; ``` Modify the key for hash bucketing, and change the number of buckets to 10 from being automatically set by StarRocks. The key used for hashing bucketing is modified to `userid, eventtime` from the original `eventtime, eventtype`. The number of buckets is modified to 10 from automatically set by StarRocks. ```SQL ALTER TABLE details DISTRIBUTED BY HASH(userid, eventtime) BUCKETS 10; `` Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> ADD COLUMN columnname columntype [KEY | aggtype] [DEFAULT "defaultvalue"] [AFTER column_name|FIRST] [TO rollupindexname] [PROPERTIES ("key"="value", ...)] ``` Note: If you add a value column to an Aggregate table, you need to specify agg_type. If you add a key column to a non-Aggregate table (such as a Duplicate Key table), you need to specify the KEY keyword. You cannot add a column that already exists in the base index to the rollup index. (You can recreate a rollup index if needed.) Syntax: Add multiple columns ```sql ALTER TABLE [<dbname>.]<tblname> ADD COLUMN (columnname1 columntype [KEY | aggtype] DEFAULT "defaultvalue", ...) [TO rollupindexname] [PROPERTIES ("key"="value", ...)] ``` Add multiple columns and use AFTER to specify locations of the added columns ```sql ALTER TABLE [<dbname>.]<tblname> ADD COLUMN columnname1 columntype [KEY | aggtype] DEFAULT "defaultvalue" AFTER column_name, ADD COLUMN columnname2 columntype [KEY | aggtype] DEFAULT "defaultvalue" AFTER column_name [, ...] [TO rollupindexname] [PROPERTIES ("key"="value", ...)] ``` Note: If you add a value column to an Aggregate table, you need to specify `agg_type`. If you add a key column to a non-Aggregate table, you need to specify the KEY keyword. You cannot add a column that already exists in the base index to the rollup index. (You can create another rollup index if needed.) Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> ADD COLUMN colname datatype [NULL] AS generation_expr [COMMENT 'string'] ``` You can add a generated column and specify its expression. can be used to precompute and store the results of expressions, which significantly accelerates queries with the same complex expressions. Since v3.1, StarRocks supports generated columns. Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> DROP COLUMN column_name [FROM rollupindexname]; ``` Note: You cannot drop partition column. If the column is dropped from the base index, it will also be dropped if it is included in the rollup index. Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> MODIFY COLUMN columnname columntype [KEY | aggtype] [NULL | NOT NULL] [DEFAULT "defaultvalue"] [AFTER column_name|FIRST] [FROM rollupindexname] [PROPERTIES ("key"="value", ...)] ``` Note: If you modify the value column in aggregation models, you need to specify agg_type. If you modify the key column in non-aggregation models, you need to specify the KEY keyword. Only the type of column can be modified. The other properties of the column remain as they are currently. (i.e. other properties need to be explicitly written in the statement according to the original property, see example 8 in the part). The partition column cannot be modified. The following types of conversions are currently supported (accuracy loss is guaranteed by the user). Convert TINYINT/SMALLINT/INT/BIGINT to TINYINT/SMALLINT/INT/BIGINT/DOUBLE. Convert TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE/DECIMAL to VARCHAR. VARCHAR supports modification of maximum length. Convert VARCHAR to TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE. Convert VARCHAR to DATE (currently support six formats: "%Y-%m-%d", "%y-%m-%d", "%Y%m%d", "%y%m%d", "%Y/%m/%d, "%y/%m/%d") Convert DATETIME to DATE(only year-month-day information is retained, i.e. `2019-12-09 21:47:05` `<-->` `2019-12-09`) Convert DATE to DATETIME (set hour, minute, second to zero, For example: `2019-12-09` `<-->` `2019-12-09 00:00:00`) Convert FLOAT to DOUBLE Convert INT to DATE (If the INT data fails to convert, the original data remains the same) Conversion from NULL to NOT NULL is not

Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> ORDER BY (columnname1, columnname2, ...) [FROM rollupindexname] [PROPERTIES ("key"="value", ...)] ``` Note: All columns in the index must be written. The value column is listed after the key column. Since v3.0, the sort keys for the Primary Key tables can be modified. v3.3 extends this support to Duplicate Key tables, Aggregate tables, and Unique Key tables. The sort keys in Duplicate Key tables and Primary Key tables can be combination of any sort columns. The sort keys in Aggregate tables and Unique Key tables must include all key columns, but the order of the columns does not need to be same as the key columns. Syntax: ```SQL ALTER TABLE [<dbname>.]<tablename> [ order_desc ] order_desc ::= ORDER BY <columnname> [, <columnname> ...] ``` Example: modify the sort keys in Primary Key tables. For example, the original table is a Primary Key table where the sort key and the primary key are coupled, which is `dt, order_id`. ```SQL create table orders ( dt date NOT NULL, order_id bigint NOT NULL, user_id int NOT NULL, merchant_id int NOT NULL, good_id int NOT NULL, good_name string NOT NULL, price int NOT NULL, cnt int NOT NULL, revenue int NOT NULL, state tinyint NOT NULL ) PRIMARY KEY (dt, order_id) PARTITION BY date_trunc('day', dt) DISTRIBUTED BY HASH(order_id); ``` Decouple the sort key from the primary key, and modify the sort key to `dt, revenue, state`. ```SQL ALTER TABLE orders ORDER BY (dt, revenue, state); ``` Syntax: ```SQL ALTER TABLE [<dbname>.]<tblname> ADD ROLLUP rollupname (columnname1, column_name2, ...) [FROM fromindexname] [PROPERTIES ("key"="value", ...)] ``` PROPERTIES: Support setting timeout time and the default timeout time is one day. Example: ```SQL ALTER TABLE [<dbname>.]<tblname> ADD ROLLUP r1(col1,col2) from r0; ``` Syntax: ```SQL ALTER TABLE [<dbname>.]<tblname> ADD ROLLUP [rollupname (columnname1, column_name2, ...) [FROM fromindexname] [PROPERTIES ("key"="value", ...)],...]; ``` Example: ```sql ALTER TABLE [<dbname>.]<tblname> ADD ROLLUP r1(col1,col2) from r0, r2(col3,col4) from r0; ``` Note: If fromindexname is not specified, then create from base index by default. The columns in the rollup table must be existing columns in from_index. In properties, user can specify the storage format. See CREATE TABLE for details. Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> DROP ROLLUP rollup_name [PROPERTIES ("key"="value", ...)]; ``` Example: ```sql ALTER TABLE [<dbname>.]<tblname> DROP ROLLUP r1; ``` Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> DROP ROLLUP [rollup_name [PROPERTIES ("key"="value", ...)],...]; ``` Example: ```sql ALTER TABLE [<dbname>.]<tblname> DROP ROLLUP r1, r2; ``` Note: You cannot drop the base index. Bitmap index supports the following modifications: Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> ADD INDEX index_name (column [, ...],) [USING BITMAP] [COMMENT 'balabala']; ``` Note: ```plain text Bitmap index is only supported for the current version. A BITMAP index is created only in a single column. ``` Syntax: ```sql DROP INDEX index_name; ``` Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> SET ("key" = "value",...) ``` Currently, StarRocks supports modifying the following table properties: `replication_num` `default.replication_num` `storagecooldownttl` `storagecooldowntime` Dynamic partitioning related properties `enablepersistentindex` `bloomfiltercolumns` `colocate_with` `bucket_size` (supported since 3.2) Note: You can also modify the properties by merging into the above operation on column. See the . Swap supports atomic exchange of two tables. Syntax: ```sql ALTER TABLE [<dbname>.]<tblname> SWAP WITH <tbl_name>; ``` StarRocks uses a compaction mechanism to merge different versions of loaded data. This feature can combine small files into large files, which effectively improves query performance. Before v3.1, compaction is performed in two ways: Automatic compaction by system: Compaction is performed at the BE level in the

Users cannot specify database or table for compaction. Users can perform compaction by calling an HTTP interface. Starting from v3.1, StarRocks offers a SQL interface for users to manually perform compaction by running SQL commands. They can choose a specific table or partition for compaction. This provides more flexibility and control over the compaction process. Shared-data clusters support this feature from v3.3.0 onwards. Syntax: ```SQL ALTER TABLE <tblname> [ BASE | CUMULATIVE ] COMPACT [ <partitionname> | ( <partition1name> [, <partition2name> ...] ) ] ``` That is: ```SQL -- Perform compaction on the entire table. ALTER TABLE <tbl_name> COMPACT -- Perform compaction on a single partition. ALTER TABLE <tblname> COMPACT <partitionname> -- Perform compaction on multiple partitions. ALTER TABLE <tblname> COMPACT (<partition1name>[,<partition2_name>,...]) -- Perform cumulative compaction. ALTER TABLE <tblname> CUMULATIVE COMPACT (<partition1name>[,<partition2_name>,...]) -- Perform base compaction. ALTER TABLE <tblname> BASE COMPACT (<partition1name>[,<partition2_name>,...]) ``` The `becompactions` table in the `informationschema` database records compaction results. You can run `SELECT * FROM informationschema.becompactions;` to query data versions after compaction. Modify the default number of replicas of the table, which is used as the default number of replicas for newly added partitions. ```sql ALTER TABLE exampledb.mytable SET ("default.replication_num" = "2"); ``` Modify the actual number of replicas of a single-partition table. ```sql ALTER TABLE exampledb.mytable SET ("replication_num" = "3"); ``` Modify data writing and replication mode among replicas. ```sql ALTER TABLE exampledb.mytable SET ("replicated_storage" = "false"); ``` This example sets the data writing and replication mode among replicas to "leaderless replication", which means data is written to multiple replicas at the same time without differentiating primary and secondary replicas. For more information, see the `replicated_storage` parameter in . Add a partition and use the default bucketing mode. The existing partition is [MIN, 2013-01-01). The added partition is [2013-01-01, 2014-01-01). ```sql ALTER TABLE exampledb.mytable ADD PARTITION p1 VALUES LESS THAN ("2014-01-01"); ``` Add a partition and use the new number of buckets. ```sql ALTER TABLE exampledb.mytable ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") DISTRIBUTED BY HASH(k1); ``` Add a partition and use the new number of replicas. ```sql ALTER TABLE exampledb.mytable ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") ("replication_num"="1"); ``` Alter the number of replicas for a partition. ```sql ALTER TABLE exampledb.mytable MODIFY PARTITION p1 SET("replication_num"="1"); ``` Batch alter the number of replicas for specified partitions. ```sql ALTER TABLE exampledb.mytable MODIFY PARTITION (p1, p2, p4) SET("replication_num"="1"); ``` Batch alter the storage medium of all partitions. ```sql ALTER TABLE exampledb.mytable MODIFY PARTITION (*) SET("storage_medium"="HDD"); ``` Drop a partition. ```sql ALTER TABLE exampledb.mytable DROP PARTITION p1; ``` Add a partition that has upper and lower boundaries. ```sql ALTER TABLE exampledb.mytable ADD PARTITION p1 VALUES [("2014-01-01"), ("2014-02-01")); ``` Create an rollup index `examplerollupindex` based on the base index (k1,k2,k3,v1,v2). Column-based storage is used. ```sql ALTER TABLE exampledb.mytable ADD ROLLUP examplerollupindex(k1, k3, v1, v2) PROPERTIES("storage_type"="column"); ``` Create an index `examplerollupindex2` based on `examplerollupindex(k1,k3,v1,v2)`. ```sql ALTER TABLE exampledb.mytable ADD ROLLUP examplerollupindex2 (k1, v1) FROM examplerollupindex; ``` Create an index `examplerollupindex3` based on the base index (k1, k2, k3, v1). The rollup timeout time is set to one hour. ```sql ALTER TABLE exampledb.mytable ADD ROLLUP examplerollupindex3(k1, k3, v1) PROPERTIES("storage_type"="column", "timeout" = "3600"); ``` Drop an index `examplerollupindex2`. ```sql ALTER TABLE exampledb.mytable DROP ROLLUP examplerollupindex2; ``` Add a key column `newcol` (non-aggregate column) after the `col1` column of `examplerollup_index`. ```sql ALTER TABLE

ADD COLUMN new_col INT KEY DEFAULT "0" AFTER col1 TO examplerollupindex; ``` Add a value column `newcol` (non-aggregate column) after the `col1` column of `examplerollup_index`. ```sql ALTER TABLE exampledb.mytable ADD COLUMN new_col INT DEFAULT "0" AFTER col1 TO examplerollupindex; ``` Add a key column `newcol` (aggregate column) after the `col1` column of `examplerollup_index`. ```sql ALTER TABLE exampledb.mytable ADD COLUMN new_col INT DEFAULT "0" AFTER col1 TO examplerollupindex; ``` Add a value column `newcol SUM` (aggregate column) after the `col1` column of `examplerollup_index`. ```sql ALTER TABLE exampledb.mytable ADD COLUMN new_col INT SUM DEFAULT "0" AFTER col1 TO examplerollupindex; ``` Add multiple columns to `examplerollupindex` (aggregate). ```sql ALTER TABLE exampledb.mytable ADD COLUMN (col1 INT DEFAULT "1", col2 FLOAT SUM DEFAULT "2.3") TO examplerollupindex; ``` Add multiple columns to `examplerollupindex` (aggregate) and specify the locations of the added columns using `AFTER`. ```sql ALTER TABLE exampledb.mytable ADD COLUMN col1 INT DEFAULT "1" AFTER `k1`, ADD COLUMN col2 FLOAT SUM AFTER `v2`, TO examplerollupindex; ``` Drop a column from `examplerollupindex`. ```sql ALTER TABLE exampledb.mytable DROP COLUMN col2 FROM examplerollupindex; ``` Modify the column type of col1 of the base index to BIGINT and put it after `col2`. ```sql ALTER TABLE exampledb.mytable MODIFY COLUMN col1 BIGINT DEFAULT "1" AFTER col2; ``` Modify the maximum length of the `val1` column of the base index to 64. The original length is 32. ```sql ALTER TABLE exampledb.mytable MODIFY COLUMN val1 VARCHAR(64) REPLACE DEFAULT "abc"; ``` Reorder the columns in `examplerollupindex`. The original column order is k1, k2, k3, v1, v2. ```sql ALTER TABLE exampledb.mytable ORDER BY (k3,k1,k2,v2,v1) FROM examplerollupindex; ``` Perform two operations (ADD COLUMN and ORDER BY) at one time. ```sql ALTER TABLE exampledb.mytable ADD COLUMN v2 INT MAX DEFAULT "0" AFTER k2 TO examplerollupindex, ORDER BY (k3,k1,k2,v2,v1) FROM examplerollupindex; ``` Alter the bloomfilter columns of the table. ```sql ALTER TABLE exampledb.mytable SET ("bloomfiltercolumns"="k1,k2,k3"); ``` This operation can also be merged into the above column operation (note that the syntax of multiple clauses is slightly different). ```sql ALTER TABLE exampledb.mytable DROP COLUMN col2 PROPERTIES ("bloomfiltercolumns"="k1,k2,k3"); ``` Alter the Colocate property of the table. ```sql ALTER TABLE exampledb.mytable SET ("colocate_with" = "t1"); ``` Alter the dynamic partition property of the table. ```sql ALTER TABLE exampledb.mytable SET ("dynamic_partition.enable" = "false"); ``` If you need to add dynamic partition properties to a table with no dynamic partition properties configured, you need to specify all the dynamic partition properties. ```sql ALTER TABLE exampledb.mytable SET ( "dynamic_partition.enable" = "true", "dynamicpartition.timeunit" = "DAY", "dynamic_partition.end" = "3", "dynamic_partition.prefix" = "p", "dynamic_partition.buckets" = "32" ); ``` Rename `table1` to `table2`. ```sql ALTER TABLE table1 RENAME table2; ``` Rename rollup index `rollup1` of `example_table` to `rollup2`. ```sql ALTER TABLE example_table RENAME ROLLUP rollup1 rollup2; ``` Rename partition `p1` of `example_table` to `p2`. ```sql ALTER TABLE example_table RENAME PARTITION p1 p2; ``` Create a bitmap index for column `siteid` in `table1`. ```sql ALTER TABLE table1 ADD INDEX index_1 (siteid) [USING BITMAP] COMMENT 'balabala'; ``` Drop the bitmap index of column `siteid` in `table1`. ```sql ALTER TABLE table1 DROP INDEX index_1; ``` Atomic swap between `table1` and `table2`. ```sql ALTER TABLE table1 SWAP WITH table2 ``` ```sql CREATE TABLE compaction_test( event_day DATE, pv BIGINT) DUPLICATE KEY(event_day) PARTITION BY datetrunc('month', eventday) DISTRIBUTED BY HASH(event_day) BUCKETS 8 PROPERTIES("replication_num" = "3"); INSERT INTO compaction_test VALUES ('2023-02-14', 2), ('2033-03-01',2); {'label':'insert_734648fa-c878-11ed-90d6-00163e0dcbfc', 'status':'VISIBLE', 'txnId':'5008'} INSERT INTO compaction_test VALUES ('2023-02-14', 2),('2033-03-01',2); {'label':'insert_85c95c1b-c878-11ed-90d6-00163e0dcbfc', 'status':'VISIBLE', 'txnId':'5009'} ALTER TABLE compaction_test COMPACT; ALTER TABLE compaction_test COMPACT p203303; ALTER TABLE compaction_test COMPACT (p202302,p203303); ALTER TABLE compaction_test CUMULATIVE COMPACT (p202302,p203303); ALTER TABLE compaction_test BASE COMPACT (p202302,p203303); ```