Purpose
This statement is used to modify the structure of an existing table. For example, you can use this statement to modify the table name and table attributes, add columns, modify column names and column attributes, and delete columns.
Syntax
alter_table_stmt:
ALTER TABLE [TEMPORARY] table_name alter_table_action_list;
alter_table_action_list:
alter_table_action [, alter_table_action ...]
alter_table_action:
ADD [COLUMN] column_definition
[ opt_position_column ]
| ADD [COLUMN] (column_definition_list)
| ADD [CONSTRAINT [constraint_name]] UNIQUE {INDEX | KEY}
[index_name] index_desc
| ADD [CONSTRAINT [constraint_name]] FOREIGN KEY
[index_name] index_desc
REFERENCES reference_definition
[match_action][opt_reference_option_list]
| ADD PRIMARY KEY (column_name)
| ADD CONSTRAINT [constraint_name] CHECK (expression)[[NOT] ENFORCED]
| ADD PARTITION (range_partition_list)
| ADD {INDEX | KEY} [index_name] [index_type] (key_part,...) [index_option_list][index_column_group_option] [algorithm = algorithm_value] [lock = lock_value]
| ADD FULLTEXT [INDEX | KEY] [index_name](column_name, [column_name ...]) [WITH PARSER tokenizer_option] [PARSER_PROPERTIES[=](parser_properties_list)] [LOCAL]
| ADD COLUMN GROUP([all columns, ]each column) [DELAYED]
| ALTER [COLUMN] column_name {
SET DEFAULT const_value
| DROP DEFAULT
}
| ALTER {CHECK | CONSTRAINT} symbol [NOT] ENFORCED
| ALTER INDEX index_name
[VISIBLE | INVISIBLE]
| CHANGE [COLUMN] column_name column_definition
| DROP [COLUMN] column_name [, DROP COLUMN column_name ...]
| DROP {PARTITION | SUBPARTITION} partition_name_list
| DROP TABLEGROUP
| DROP FOREIGN KEY fk_name
| DROP PRIMARY KEY [, ADD PRIMARY KEY (column)]
| DROP CHECK constraint_name
| DROP COLUMN GROUP([all columns, ]each column)
| MODIFY [COLUMN] column_definition
| RENAME COLUMN old_col_name [TO|AS] new_col_name
| RENAME [TO|AS] table_name
| RENAME {INDEX | KEY} old_index_name [TO|AS] new_index_name
| [SET] table_option_list
| TRUNCATE {PARTITION | SUBPARTITION} partition_name_list
| EXCHANGE PARTITION partition_name WITH TABLE origin_table_name WITHOUT VALIDATION
| REORGANIZE PARTITION partition_name INTO (split_range_partition_list)
| PARTITION BY {RANGE [COLUMNS]([column_name_list]) [SIZE('size_value')] [range_partition_list]
| partition_option}
| MODIFY PARTITION partition_name ADD SUBPARTITION (add_subpartition_option)
| FORCE
column_definition_list:
column_definition [, column_definition ...]
column_definition:
column_name data_type
[DEFAULT const_value] [AUTO_INCREMENT]
[NULL | NOT NULL] [[PRIMARY] KEY] [UNIQUE [KEY]] [COMMENT string_value] [SKIP_INDEX(skip_index_option_list)] [ opt_position_column ]
skip_index_option_list:
skip_index_option [,skip_index_option ...]
skip_index_option:
MIN_MAX
| SUM
opt_position_column:
FIRST | BEFORE | AFTER column_name
index_desc:
(column_desc_list) [index_type] [index_option_list]
match_action:
MATCH {SIMPLE | FULL | PARTIAL}
opt_reference_option_list:
reference_option [,reference_option ...]
reference_option:
ON {DELETE | UPDATE} {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}
column_desc_list:
column_desc [, column_desc ...]
column_desc:
column_name [(length)] [ASC | DESC]
key_part:
{index_col_name [(length)] | (expr)} [ASC | DESC]
index_type:
USING BTREE
index_option_list:
index_option [ index_option ...]
index_option:
[GLOBAL | LOCAL]
| block_size
| compression
| STORING(column_name_list)
| COMMENT string_value
index_column_group_option:
WITH COLUMN GROUP([all columns, ]each column)
algorithm_value:
default
| inplace
| copy
| instant
lock_value:
default
| none
| shared
| exclusive
tokenizer_option:
SPACE
| NGRAM
| BENG
| IK
| NGRAM2
parser_properties_list:
parser_properties, [parser_properties]
parser_properties:
min_token_size = int_value
| max_token_size = int_value
| ngram_token_size = int_value
| ik_mode = 'char_value'
| min_ngram_size = int_value
| max_ngram_size = int_value
table_option_list:
table_option [ table_option ...]
table_option:
TABLEGROUP = tablegroup_name
| block_size
| lob_inrow_threshold [=] num
| compression
| AUTO_INCREMENT [=] INT_VALUE
| COMMENT string_value
| parallel_clause
| TABLE_MODE [=] 'table_mode_value'
| AUTO_INCREMENT_CACHE_SIZE [=] INT_VALUE
| READ {ONLY | WRITE}
| DUPLICATE_SCOPE= 'none | cluster'
| enable_macro_block_bloom_filter [=] {True | False}
| DYNAMIC_PARTITION_POLICY [=] (dynamic_partition_policy_list)
| SEMISTRUCT_ENCODING_TYPE [=] 'encoding'
parallel_clause:
{NOPARALLEL | PARALLEL integer}
table_mode_value:
NORMAL
| QUEUING
| MODERATE
| SUPER
| EXTREME
dynamic_partition_policy_list:
dynamic_partition_policy_option [, dynamic_partition_policy_option ...]
dynamic_partition_policy_option:
ENABLE = {true | false}
| PRECREATE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}
| EXPIRE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}
partition_option:
PARTITION BY HASH(expression)
[subpartition_option] PARTITIONS partition_count
| PARTITION BY KEY([column_name_list])
[subpartition_option] PARTITIONS partition_count
| PARTITION BY RANGE {(expression) | COLUMNS (column_name_list)}
[subpartition_option] (range_partition_list)
subpartition_option:
SUBPARTITION BY HASH(expression)
SUBPARTITIONS subpartition_count
| SUBPARTITION BY KEY(column_name_list)
SUBPARTITIONS subpartition_count
| SUBPARTITION BY RANGE {(expression) | COLUMNS (column_name_list)}
(range_subpartition_list)
split_range_partition_list:
PARTITION split_partition_name VALUES LESS THAN (value)
[, PARTITION split_partition_name VALUES LESS THAN (value) ...]
, PARTITION split_partition_name VALUES LESS THAN (source_value)
range_partition_list:
range_partition [, range_partition ...]
range_partition:
PARTITION partition_name
VALUES LESS THAN {(expression_list) | MAXVALUE}
range_subpartition_list:
range_subpartition [, range_subpartition ...]
range_subpartition:
SUBPARTITION subpartition_name
VALUES LESS THAN {(expression_list) | MAXVALUE}
expression_list:
expression [, expression ...]
column_name_list:
column_name [, column_name ...]
partition_name_list:
partition_name [, partition_name ...]
partition_count | subpartition_count:
INT_VALUE
add_subpartition_option:
{SUBPARTITION subpartition_name VALUES LESS THAN range_partition_expr
[, SUBPARTITION subpartition_name VALUES LESS THAN range_partition_expr] ...}
| {SUBPARTITION subpartition_name VALUES IN list_partition_expr
[, SUBPARTITION subpartition_name VALUES IN list_partition_expr] ...}
Parameter description
| Parameter | Description |
|---|---|
| TEMPORARY | Optional. Specifies to modify a temporary table.
NoteThis parameter is supported since OceanBase Database V4.3.5 BP4. |
| ADD [COLUMN] | Adds a column. The system supports adding a generated column. |
| [FIRST | BEFORE | AFTER column_name] | Specifies whether to make the new column the first column of the table, or to place the new column before or after the column_name column. OceanBase Database supports specifying the column position only in the ADD COLUMN clause. |
| CHANGE [COLUMN] | Modifies the column name and column definition. You can increase the length of specific character data types such as VARCHAR, VARBINARY, and CHAR. |
| MODIFY [COLUMN] | Modifies the column attributes. |
| ALTER [COLUMN] {SET DEFAULT const_value | DROP DEFAULT} | Modifies the default value of the column. |
| DROP [COLUMN] | Drops a column.
NoticeThe primary key column cannot be dropped. |
| ADD FOREIGN KEY | Adds a foreign key. If you do not specify a foreign key name, the system generates one based on the table name and the current time. (For example, the name of a foreign key created for the t1 table on August 1, 2021, at 00:00:00 is t1_OBFK_1627747200000000). A foreign key can reference data in another table. When the UPDATE or DELETE operation affects the key values of the matching rows in the parent table, the result depends on the ON UPDATE and ON DELETE clauses.
SET DEFAULT operation is supported. |
| ADD PRIMARY KEY | Adds a primary key. You can specify one or more columns as the primary key. If multiple columns are specified, they form a composite primary key. |
| ADD {INDEX | KEY} | Adds an index. For more information, see ADD INDEX KEY. |
| ADD FULLTEXT [INDEX | KEY] | Adds a full-text index. For more information, see Create a full-text index. |
| WITH PARSER tokenizer_option | Optional. Specifies the tokenizer for the full-text index. For more information, see tokenizer_option. |
| PARSER_PROPERTIES[=](parser_properties_list) | Optional. Specifies the properties of the tokenizer. For more information, see parser_properties.
NoteFor OceanBase Database V4.3.5, the |
| ALTER INDEX | Modifies whether the index is visible. If the index is invisible, the SQL optimizer does not select it. |
| key_part | Creates a (function) index. |
| index_col_name | Specifies the name of the column in the index. Each column name can be followed by ASC (ascending) but not by DESC (descending). The default is ascending. The sorting method for creating the index is as follows: First, the values of the first column in index_col_name are sorted. For records with the same value in the first column, the values of the next column name are sorted. This process continues. |
| expr | Specifies a valid function index expression, which can be a Boolean expression, such as c1=c1. Notice OceanBase Database does not support creating a function index on a generated column. |
| ADD [PARTITION] | Adds a partition to a partitioned table. |
| DROP {PARTITION | SUBPARTITION} | Drops a partition:
Notice When you drop a partition, make sure that no active transaction or query is running in the partition. Otherwise, an SQL statement error may be returned, or some abnormal situations may occur. |
| TRUNCATE {PARTITION | SUBPARTITION} | Deletes data in a partition:
Notice When you delete data in a partition, make sure that no active transaction or query is running in the partition. Otherwise, an SQL statement error may be returned, or some abnormal situations may occur. |
| RENAME COLUMN old_col_name TO new_col_name | Renames a column. You can rename a column without changing the column definition.
Notice
|
| RENAME [TO] table_name | Renames a table.
NoticeDuring the |
| RENAME {INDEX | KEY} | Renames an index or a key. |
| DROP [TABLEGROUP] | Drops a table group. |
| DROP [FOREIGN KEY] | Drops a foreign key. |
| DROP [PRIMARY KEY] | Drops a primary key.
NoteFor the MySQL mode, you cannot drop a primary key in the following cases:
|
| [SET] table_option | Sets a table-level attribute. Valid values:
|
| CHECK | Modifies the CHECK constraint. Valid values:
|
| [NOT] ENFORCED | Specifies whether to enforce the CHECK constraint named constraint_name.
|
| ADD COLUMN GROUP([all columns, ]each column) [DELAYED] | Converts the table to a column-store table. The specific description is as follows:
|
| DROP COLUMN GROUP([all columns, ]each column) | Removes the storage format of the table. The specific description is as follows:
|
| index_column_group_option | Specifies the index options. The specific description is as follows:
|
| SKIP_INDEX | Modifies the Skip Index attribute of a column. Valid values:
Notice
|
| EXCHANGE PARTITION partition_name WITH TABLE origin_table_name | Specifies to exchange a partition. In this statement, partition_name specifies the name of the partition in the partitioned table. origin_table_name specifies the name of the source table, which can be a non-partitioned table or a partitioned table.
NoteFor OceanBase Database V4.3.5, data exchange between a partition of a partitioned table and a partition of a non-partitioned table is supported since V4.3.5 BP3. |
| TABLE_MODE | Optional. Specifies the threshold and strategy for triggering a major compaction, which controls the behavior of a major compaction after data is compacted. For more information, see table_mode_value. |
| AUTO_INCREMENT_CACHE_SIZE | Specifies the number of cached auto-increment values. The default value is 0, which indicates that this option is not configured. The system uses the tenant-level setting for auto_increment_cache_size as the cache size for the auto-increment column. |
| READ {ONLY | WRITE} | Specifies the read/write permissions of a table. The specific description is as follows:
|
| DUPLICATE_SCOPE | Modifies the duplicate table attribute. Valid values:
|
| enable_macro_block_bloom_filter [=] {True | False} | Specifies whether to persist the macro block-level Bloom filter. The options are as follows:
NoteFor OceanBase Database V4.3.5, the |
| DYNAMIC_PARTITION_POLICY [=] (dynamic_partition_policy_list) | Modifies the dynamic partition management attribute of a table. dynamic_partition_policy_list specifies the list of configurable parameters of the dynamic partition strategy. The parameters are separated with commas. For more information, see dynamic_partition_policy_option.
NoteFor OceanBase Database V4.3.5, the dynamic partition management attribute of a table is supported since V4.3.5 BP2. |
| REORGANIZE PARTITION | Specifies to manually split a partition. The related parameters are as follows:
NoticeIn MySQL mode, the current version supports splitting only one partition into multiple partitions and does not support splitting multiple partitions into multiple partitions. |
| PARTITION BY | Modifies the automatic partition attribute or partitioning rule of a table. The related parameters are as follows:
|
| MODIFY PARTITION partition_name ADD SUBPARTITION (add_subpartition_option) | Specifies to add a subpartition.
Notice
|
| add_subpartition_option | Specifies the definition of the new subpartition. |
| range_partition_expr | Specifies the RANGE or RANGE COLUMNS partitioning expression. |
| list_partition_expr | Specifies the LIST or LIST COLUMNS partitioning expression. |
| FORCE | Specifies to drop the obsolete column.
Note
|
| SEMISTRUCT_ENCODING_TYPE | Optional. Specifies the semi-structured encoding type. Valid values:
|
ADD INDEX KEY
ADD {INDEX | KEY} [index_name] [index_type] (key_part,...) [index_option_list][index_column_group_option] [algorithm] [lock]INDEX | KEY: Specifies the key or index for the created table. These two keywords are equivalent.index_name: Optional. Specifies the index name. If no index name is specified, the first column referenced by the index is used as the index name. If the index name is duplicated, the index name is specified as underscore (_) plus the sequence number.index_type: Optional. Specifies the index type.key_part: Specifies the column name or expression to be included in the index.index_option: Optional. Specifies the index options.algorithm: Specifies the underlying algorithm type used to execute DDL operations (such as adding an index).<main id="notice"type='notice'>Notice
In the current version, the
algorithmparameter is for compatibility with MySQL syntax and has no practical effect.lock: Specifies the table lock level applied during DDL operations, controlling the granularity of concurrent access.<main id="notice"type='notice'>Notice
In the current version, the
lockparameter is for compatibility with MySQL syntax and has no practical effect.
table_mode_value
Note
In the following TABLE_MODE modes, except for NORMAL, all other modes represent a QUEUING table. This is the most basic table type. The following modes (excluding NORMAL) indicate more aggressive compaction strategies.
NORMAL: the default value, indicating normal. In this mode, the probability of triggering a major compaction after a minor compaction is very low.QUEUING: in this mode, the probability of triggering a major compaction after a minor compaction is low.MODERATE: indicating moderate. In this mode, the probability of triggering a major compaction after a minor compaction is moderate.SUPER: indicating super. In this mode, the probability of triggering a major compaction after a minor compaction is high.EXTREME: indicating extreme. In this mode, the probability of triggering a major compaction after a minor compaction is high.
For more information about compaction, see Adaptive compaction.
tokenizer_option
SPACE: the default value, which specifies to split text by spaces. You can specify the following parameters:Property Value range min_token_size [1, 16] max_token_size [10, 84] NGRAM: specifies to split text by using the N-Gram (Chinese) tokenizer. You can specify the following parameters:Property Value range ngram_token_size [1, 10] NGRAM2: specifies to split text into continuous characters whose lengths range frommin_ngram_sizetomax_ngram_size. You can specify the following parameters:Property Value range min_ngram_size [1, 16] max_ngram_size [1, 16] Note
For OceanBase Database V4.3.5, the
NGRAM2tokenizer is supported since V4.3.5 BP2.BENG: specifies to split text by using the basic English tokenizer. You can specify the following parameters:Parameter Value range min_token_size [1, 16] max_token_size [10, 84] IK: specifies to split text by using the Chinese IK tokenizer. Only theutf-8character set is supported. You can specify the following parameters:Property Value range ik_mode smartmax_word
Note
For OceanBase Database V4.3.5, the
IKtokenizer is supported since V4.3.5 BP1.
You can call the TOKENIZE function to view the tokenization results of text in JSON format by using the specified tokenizer.
parser_properties
min_token_size: the minimum token length. The default value is 3, and the value range is 1 to 16.max_token_size: the maximum token length. The default value is 84, and the value range is 10 to 84.ngram_token_size: the token length of theNGRAMtokenizer. This parameter is valid only for theNGRAMtokenizer. The default value is 2, and the value range is 1 to 10.ik_mode: the mode of theIKtokenizer. Valid values:smartandmax_word.smart: the default value. This mode specifies to use the words in the dictionary to improve the accuracy of tokenization and prioritize the boundaries of the words in the dictionary, which may reduce unnecessary expansion.max_word: this mode specifies to identify the words defined in the dictionary but does not affect the maximum expansion of tokenization. Even if the dictionary defines a word, themax_wordmode will still try to split the text into more words.
min_ngram_size: the minimum token length. The value range is [1,16].max_ngram_size: the maximum token length. The value range is [1,16].
Here is an example:
Create a table named
tbl1.CREATE TABLE tbl1 (col1 VARCHAR(200), col2 TEXT);Add a full-text index named
fidxto thetbl1table.ALTER TABLE tbl1 ADD FULLTEXT INDEX fidx(col2) WITH PARSER ik PARSER_PROPERTIES=(ik_mode='max_word');
dynamic_partition_policy_option
ENABLE = {true | false}: specifies whether to enable dynamic partition management. Valid values are as follows:true: specifies to enable dynamic partition management. This value is the default.false: specifies to disable dynamic partition management.
PRECREATE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}: specifies the precreate time. A dynamic partition management job is scheduled, and partitions are precreated such that the maximum partition upper bound > now() + precreate_time. Valid values are as follows:-1: specifies not to precreate any partitions. This value is the default.0: specifies to precreate only the current partition.n {hour | day | week | month | year}: specifies to precreate partitions within the specified time span. For example,3 hourspecifies to precreate partitions within the last 3 hours.
Note
- When multiple partitions are to be precreated, the interval between partition boundaries is
TIME_UNIT. - The first precreated partition boundary is the ceiling of the maximum existing partition boundary by
TIME_UNIT.
EXPIRE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}: specifies the partition expiration time. A dynamic partition management job is scheduled, and all partitions whose upper bound is earlier than now() - expire_time are deleted. Valid values are as follows:-1: specifies that partitions never expire. This value is the default.0: specifies that all partitions except the current one expire.n {hour | day | week | month | year}: specifies the partition expiration time. For example,1 dayspecifies that partitions expire after 1 day.
For more information about how to modify a dynamic partition table, see Modify a dynamic partition table.
Here is an example:
ALTER TABLE tbl2 SET DYNAMIC_PARTITION_POLICY(
ENABLE = true,
PRECREATE_TIME = '1 day',
EXPIRE_TIME = '-1'
);
Example
Add and drop columns
Create a sample table named tbl1 and execute the DESCRIBE command to view the table information.
obclient> CREATE TABLE tbl1 (c1 INT(11) PRIMARY KEY,c2 VARCHAR(50));
Query OK, 0 rows affected
obclient> DESCRIBE tbl1;
+-------+------------+----------+--------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+----------+--------+---------+-------+
| c1 | int(11) | NO | PRI | NULL | |
| c2 | varchar(50)| YES | | NULL | |
+-------+------------+----------+--------+---------+-------+
Add the
c3column and execute theDESCRIBEcommand to view the table information.obclient> ALTER TABLE tbl1 ADD c3 INT; Query OK, 1 row affected obclient> DESCRIBE tbl1; +-------+------------+----------+--------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+----------+--------+---------+-------+ | c1 | int(11) | NO | PRI | NULL | | | c2 | varchar(50)| YES | | NULL | | | c3 | int(11) | YES | | NULL | | +-------+------------+----------+--------+---------+-------+ 3 row affectedDrop the
c3column and execute theDESCRIBEcommand to view the table information.obclient> ALTER TABLE tbl1 DROP c3; Query OK, 1 row affected obclient> DESCRIBE tbl1; +-------+------------+----------+--------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+----------+--------+---------+-------+ | c1 | int(11) | NO | PRI | NULL | | | c2 | varchar(50)| YES | | NULL | | +-------+------------+----------+--------+---------+-------+ 2 row affectedRename the
c2column in thetbl1table toc3and execute theDESCRIBEcommand to view the table information.obclient> ALTER TABLE tbl1 CHANGE COLUMN c2 c3 VARCHAR(50); Query OK, 1 row affected obclient> DESCRIBE tbl1; +-------+------------+----------+--------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+----------+--------+---------+-------+ | c1 | int(11) | NO | PRI | NULL | | | c3 | varchar(50)| YES | | NULL | | +-------+------------+----------+--------+---------+-------+ 2 rows affectedAdd the
c4column to thetbl1table and set it as the first column of the table, and execute theDESCRIBEcommand to view the table information.obclient> ALTER TABLE tbl1 ADD COLUMN c4 INTEGER FIRST; Query OK, 1 row affected obclient> DESCRIBE tbl1; +-------+------------+----------+--------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+----------+--------+---------+-------+ | c4 | int(11) | YES | | NULL | | | c1 | int(11) | NO | PRI | NULL | | | c3 | varchar(50)| YES | | NULL | | +-------+------------+----------+--------+---------+-------+ 3 row affectedAdd the
c2column after thec1column and execute theDESCRIBEcommand to view the table information.obclient> ALTER TABLE tbl1 ADD COLUMN c2 INTEGER AFTER c1; Query OK, 1 row affected obclient> DESCRIBE tbl1; +-------+------------+----------+--------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+----------+--------+---------+-------+ | c4 | int(11) | YES | | NULL | | | c1 | int(11) | NO | PRI | NULL | | | c2 | int(11) | YES | | NULL | | | c3 | varchar(50)| YES | | NULL | | +-------+------------+----------+--------+---------+-------+ 4 row affectedAdd the
c5column before thec4column and execute theDESCRIBEcommand to view the table information.obclient> ALTER TABLE tbl1 ADD COLUMN c5 INT BEFORE c4; Query OK, 1 row affected obclient> DESCRIBE tbl1; +-------+------------+----------+--------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+----------+--------+---------+-------+ | c5 | int(11) | YES | | NULL | | | c4 | int(11) | YES | | NULL | | | c1 | int(11) | NO | PRI | NULL | | | c2 | int(11) | YES | | NULL | | | c3 | varchar(50)| YES | | NULL | | +-------+------------+----------+--------+---------+-------+ 5 row affectedAdd the foreign key constraint
fk1to thetbl2table. When theUPDATEoperation affects the parent table's key values that match the rows in the child table, execute theSET NULLoperation.obclient> CREATE TABLE tbl2(c1 INT PRIMARY KEY,c2 INT); Query OK, 0 row affected obclient> CREATE TABLE tbl3(c1 INT PRIMARY KEY,c2 INT); Query OK, 0 row affected obclient> ALTER TABLE tbl2 ADD CONSTRAINT fk1 FOREIGN KEY (c2) REFERENCES tbl3(c1) ON UPDATE SET NULL; Query OK, 0 row affectedDrop the foreign key constraint
fk1from thetbl3table.obclient> ALTER TABLE tbl2 DROP FOREIGN KEY fk1; Query OK, 0 row affectedDrop the primary key from the
tbl2table.obclient> ALTER TABLE tbl2 DROP PRIMARY KEY; Query OK, 0 row affected
Index operations
Rename the index
ind1in thetbl2table toind2.obclient> CREATE TABLE tbl2(c1 INT(11) PRIMARY KEY,c2 INT(50)); Query OK, 0 row affected obclient> CREATE INDEX ind1 ON tbl2 (c2 ASC); Query OK, 0 row affected obclient> ALTER TABLE tbl2 RENAME INDEX ind1 TO ind2; Query OK, 0 row affectedCreate an index named
ind3on thetbl2table, which references thec1andc2columns.obclient> ALTER TABLE tbl2 ADD INDEX ind3 (c1,c2); Query OK, 0 row affectedYou can run the
SHOW INDEXstatement to view the created index.obclient> SHOW INDEX FROM tbl2; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+ | tbl2 | 0 | PRIMARY | 1 | c1 | A | NULL | NULL | NULL | | BTREE | available | | YES | | tbl2 | 1 | ind2 | 1 | c2 | A | NULL | NULL | NULL | YES | BTREE | available | | YES | | tbl2 | 1 | ind3 | 1 | c1 | A | NULL | NULL | NULL | | BTREE | available | | YES | | tbl2 | 1 | ind3 | 2 | c2 | A | NULL | NULL | NULL | YES | BTREE | available | | YES | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+ 4 rows in setDrop the index
ind2from thetbl2table.obclient> ALTER TABLE tbl2 DROP INDEX ind2; Query OK, 0 row affectedNote
In actual operations, you can use the above methods to implement atomic index changes.
Add three function indexes to the
t1_functable, one of which is namedi2, and the other two are automatically generated by the system, with names in the format offunctional_indexfollowed by a number.obclient> ALTER TABLE t1_func ADD INDEX ((CONCAT(c1,'a'))); Query OK, 0 rows affected obclient> ALTER TABLE t1_func ADD INDEX ((c1+1)); Query OK, 0 rows affected obclient> ALTER TABLE t1_func ADD INDEX i2 ((CONCAT(c1,'a'))); Query OK, 0 rows affected obclient> SHOW CREATE TABLE t1_func; +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t1_func | CREATE TABLE `t1_func` ( `c1` int(11) DEFAULT NULL, `c2` int(11) DEFAULT NULL, KEY `i1` (((`c1` + `c2`) < 1)) BLOCK_SIZE 16384 LOCAL, KEY `functional_index` (concat(`c1`,'a')) BLOCK_SIZE 16384 LOCAL, KEY `functional_index_2` ((`c1` + 1)) BLOCK_SIZE 16384 LOCAL, KEY `i2` (concat(`c1`,'a')) BLOCK_SIZE 16384 LOCAL ) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 | +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in setCreate a column store index for the table.
Run the following SQL statement to create a table named
tbl3.CREATE TABLE tbl3 (col1 INT, col2 VARCHAR(50));Create a column store index named
idx1_tbl3on thetbl3table, which references thecol1column.ALTER TABLE tbl3 ADD INDEX idx1_tbl3 (col1) WITH COLUMN GROUP(each column);
Make the index invisible.
Note
After an index is made invisible, you can see the
/*!80000 INVISIBLE */tag in the table schema.Create a table named
tbl4.CREATE TABLE tbl4 (col1 INT PRIMARY KEY, col2 INT, col3 INT);Create an index named
idx1_tbl4.CREATE INDEX idx1_tbl4 ON tbl4(col2);Make the
idx1_tbl4index invisible.ALTER TABLE tbl4 ALTER INDEX idx1_tbl4 INVISIBLE;View the structure of the
tbl4table again.SHOW CREATE TABLE tbl4;The returned result is as follows:
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tbl4 | CREATE TABLE `tbl4` ( `col1` int(11) NOT NULL, `col2` int(11) DEFAULT NULL, `col3` int(11) DEFAULT NULL, PRIMARY KEY (`col1`), KEY `idx1_tbl4` (`col2`) BLOCK_SIZE 16384 LOCAL /*!80000 INVISIBLE */ ) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 WITH COLUMN GROUP(each column) | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set
Partitioning operations
Clear all data in the
M202001andM202002partitions of the partitioned tablet_log_part_by_range.obclient> CREATE TABLE t_log_part_by_range ( log_id bigint NOT NULL , log_value varchar(50) , log_date timestamp NOT NULL ) PARTITION BY RANGE(UNIX_TIMESTAMP(log_date)) ( PARTITION M202001 VALUES LESS THAN(UNIX_TIMESTAMP('2020/02/01')) , PARTITION M202002 VALUES LESS THAN(UNIX_TIMESTAMP('2020/03/01')) , PARTITION M202003 VALUES LESS THAN(UNIX_TIMESTAMP('2020/04/01')) , PARTITION M202004 VALUES LESS THAN(UNIX_TIMESTAMP('2020/05/01')) , PARTITION M202005 VALUES LESS THAN(UNIX_TIMESTAMP('2020/06/01')) ); Query OK, 0 rows affected obclient> ALTER TABLE t_log_part_by_range TRUNCATE PARTITION M202001, M202002; Query OK, 0 rows affectedAdd the
M202006partition to the partitioned tablet_log_part_by_range.obclient> CREATE TABLE t_log_part_by_range ( log_id bigint NOT NULL , log_value varchar(50) , log_date timestamp NOT NULL ) PARTITION BY RANGE(UNIX_TIMESTAMP(log_date)) ( PARTITION M202001 VALUES LESS THAN(UNIX_TIMESTAMP('2020/02/01')) , PARTITION M202002 VALUES LESS THAN(UNIX_TIMESTAMP('2020/03/01')) , PARTITION M202003 VALUES LESS THAN(UNIX_TIMESTAMP('2020/04/01')) , PARTITION M202004 VALUES LESS THAN(UNIX_TIMESTAMP('2020/05/01')) , PARTITION M202005 VALUES LESS THAN(UNIX_TIMESTAMP('2020/06/01')) ); Query OK, 0 rows affected obclient> ALTER TABLE t_log_part_by_range ADD PARTITION (PARTITION M202006 VALUES LESS THAN(UNIX_TIMESTAMP('2020/07/01')) );
Change the degree of parallelism
Change the degree of parallelism of
tbl3to2.obclient> ALTER TABLE tbl3 PARALLEL 2;You can change the degree of parallelism of a table by using either
ALTER TABLE table_name PARALLEL int;or thePARALLELhint. The syntax for using thePARALLELhint isalter /*+ parallel(int) */ table.
Operations on column types
Modify the
col1column in thetbl4table to an auto-increment column.obclient> CREATE TABLE tbl4 (col1 BIGINT(10) NOT NULL,col2 INT); Query OK, 0 rows affected obclient> ALTER TABLE tbl4 MODIFY col1 BIGINT(10) AUTO_INCREMENT; Query OK, 0 rows affectedAdd the
col1column as the primary key of thetbl4table and change the primary key tocol2.obclient> ALTER TABLE tbl4 ADD PRIMARY KEY (col1); Query OK, 0 rows affected obclient> ALTER TABLE tbl4 DROP PRIMARY KEY,ADD PRIMARY KEY (`col2`); Query OK, 0 rows affectedAdd a
CHECKconstraint.obclient> CREATE TABLE tbl7(col1 VARCHAR(10),col2 VARCHAR(10)); Query OK, 0 rows affected obclient> ALTER TABLE tbl7 ADD CONSTRAINT my_check CHECK (col1> col2) ; Query OK, 0 rows affectedDelete the
CHECKconstraint from thetbl7table.obclient> ALTER TABLE tbl7 DROP CHECK my_check; Query OK, 0 rows affectedChange the column type to
NOT NULL.obclient> CREATE TABLE dept( deptno NUMBER(2,0), dname VARCHAR(14), location VARCHAR(13), CONSTRAINT pk_dept PRIMARY KEY(deptno) ); Query OK, 0 rows affected obclient> CREATE TABLE emp( empno NUMBER(4,0) NOT NULL, empname VARCHAR(10) NOT NULL, job VARCHAR(9) NOT NULL, mgr NUMBER(4,0) NOT NULL, hiredate DATE NOT NULL, sal NUMBER(7,2) DEFAULT NULL, comm NUMBER(7,2) DEFAULT NULL, deptno NUMBER(2,0) DEFAULT NULL, CONSTRAINT PK_emp PRIMARY KEY (empno), CONSTRAINT FK_deptno FOREIGN KEY (deptno) REFERENCES dept (deptno) ); Query OK, 0 rows affected obclient> ALTER TABLE emp MODIFY deptno NUMBER(2,0) DEFAULT '12' NOT NULL; Query OK, 0 rows affected
Change the column name and add a NOT NULL column constraint
Notice
Modify the column name and add a not null constraint only when the following conditions are met:
- You can change the name and constraint of only one column at a time. Multi-column operations are not supported.
- You can add only
not nullconstraints. - You can perform only the
alter_columnoperation. Operations such as index and partition creation are not supported. - The column whose name is changed and the column to which the constraint is added must be the same column.
obclient> ALTER TABLE test_alter1 MODIFY COLUMN `C1` varchar(10) NOT NULL;
Query OK, 0 rows affected (2.421 sec)
Add the NOT NULL constraint to two columns
Notice
Add the NOT NULL constraint to two columns only when the following conditions are met:
- You can add constraints to only two columns.
- You can add only
not nullconstraints. - You can perform only the
alter_columnoperation. Operations such as index and partition creation are not supported. - You cannot modify other columns except the two columns to which the constraints are added.
Run the following command to add the NOT NULL constraint to the C1 and c2 columns:
obclient> ALTER TABLE test_alter4 MODIFY COLUMN c1 varchar(10) NOT NULL, MODIFY COLUMN c2 varchar(10) NOT NULL;
Query OK, 0 rows affected (2.605 sec)
Change the type of a column with a prefix index
Notice
Change the type of a column with a prefix index only when the following conditions are met:
- The original column type is
char. - The target column type is
varchar. - The lengths of the original and target columns are the same.
Run the following command to create a table named
test_alter5that contains thec1column. The data type of thec1column isCHAR(20), and a prefix index namedidx_c1is created on thec1column:obclient> CREATE TABLE test_alter5 (c1 char(20), KEY idx_c1(c1(10)));Execute the following command to change the data type of the
c1column tovarchar(20):obclient> ALTER TABLE test_alter5 MODIFY COLUMN c1 varchar(20);
Change the foreign key constraint rules
Run the following command to create a table named
t1and add a unique constraint to the integer columnc1:obclient> CREATE TABLE t1(c1 int unique key);Run the following command to create a table named
t2that contains an integer columnc1and define a foreign key constraint:obclient> CREATE TABLE t2(c1 int, CONSTRAINT fk_cst_test FOREIGN KEY (c1) REFERENCES t1(c1) on update set null on delete no action);Run the following command to query the system table
INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTSand obtain the update and delete rules of the foreign key constraintfk_cst_test:obclient> SELECT update_rule, delete_rule FROM information_schema.referential_constraints WHERE CONSTRAINT_NAME = 'fk_cst_test';The return result is as follows:
+-------------+-------------+ | update_rule | delete_rule | +-------------+-------------+ | SET NULL | NO ACTION | +-------------+-------------+UPDATE_RULE:SET NULL(the foreign key is set toNULLduring an update).DELETE_RULE:NO ACTION(a constraint is checked during a deletion, which may prevent the operation).
Rename a column
The
RENAME COLUMNstatement does not change the column definition but only modifies the column name. If the target name already exists in the table, theRENAME COLUMNstatement will fail. However, renaming the column back to its original name will not cause any errors.obclient> CREATE TABLE tbl8 (a INT, b INT); Query OK, 0 rows affected obclient> ALTER TABLE tbl8 RENAME COLUMN a TO b; ERROR 1060 (42S21): Duplicate column name 'b' obclient> ALTER TABLE tbl8 RENAME COLUMN a TO a; Query OK, 0 rows affectedIf an index exists on the column to be renamed, the
RENAME COLUMNstatement can still be executed, and the index definition will be automatically updated.obclient> CREATE TABLE tbl9 (a INT, b INT, index idx_a(a)); Query OK, 0 rows affected obclient> SHOW INDEX FROM tbl9; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ | tbl9 | 1 | idx_a | 1 | a | A | NULL | NULL | NULL | YES | BTREE | available | | YES | NULL | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ 1 row in set obclient> ALTER TABLE tbl9 RENAME COLUMN a TO c; Query OK, 0 rows affected obclient> SHOW INDEX FROM tbl9; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ | tbl9 | 1 | idx_a | 1 | c | A | NULL | NULL | NULL | YES | BTREE | available | | YES | NULL | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ 1 row in setIf the column to be renamed is referenced by a prefix index, the
RENAME COLUMNstatement can still be executed, and the prefix index supports cascading updates.DROP TABLE tbl9; obclient> CREATE TABLE tbl9 (c1 INT PRIMARY KEY, c2 BLOB, c3 INT, INDEX i1 (c2(10))); Query OK, 0 rows affected obclient> ALTER TABLE tbl9 RENAME COLUMN c2 TO c2_, RENAME COLUMN c1 TO c2_1; DESC tbl9; Query OK, 0 rows affected obclient> SHOW INDEX FROM tbl9; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ | tbl9 | 0 | PRIMARY | 1 | c2_1 | A | NULL | NULL | NULL | | BTREE | available | | YES | NULL | | tbl9 | 1 | i1 | 1 | c2_ | A | NULL | 10 | NULL | YES | BTREE | available | | YES | NULL | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+-----------+---------------+---------+------------+ 2 rows in setIf a foreign key constraint exists on the column to be renamed, the
RENAME COLUMNstatement can still be executed, and the foreign key constraint will be automatically updated.obclient> CREATE TABLE tbl10 (a INT PRIMARY KEY); Query OK, 0 rows affected obclient> CREATE TABLE tbl11(b INT, FOREIGN KEY (b) REFERENCES tbl10(a)); obclient> SHOW CREATE TABLE tbl11; +-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tbl11 | CREATE TABLE `tbl11` ( `b` int(11) DEFAULT NULL, CONSTRAINT `tbl11_OBFK_1694681944513338` FOREIGN KEY (`b`) REFERENCES `test`.`tbl10`(`a`) ON UPDATE RESTRICT ON DELETE RESTRICT ) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 | +-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set obclient> ALTER TABLE tbl10 RENAME COLUMN a TO c; Query OK, 0 rows affected obclient> SHOW CREATE TABLE tbl11; +-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tbl11 | CREATE TABLE `tbl11` ( `b` int(11) DEFAULT NULL, CONSTRAINT `tbl11_OBFK_1694681944513338` FOREIGN KEY (`b`) REFERENCES `test`.`tbl10`(`c`) ON UPDATE RESTRICT ON DELETE RESTRICT ) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 | +-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set
OceanBase Database does not support modifying or automatically updating the column name in the following scenarios:
The column to be renamed is referenced by a generated list expression. Modifying the column name is not supported, and an error will be returned upon execution.
obclient> CREATE TABLE tbl12(a INT, b INT AS (a + 1), c INT, d INT, CONSTRAINT d_check CHECK(d > 0)) PARTITION BY HASH(c + 1) PARTITIONS 2; obclient> ALTER TABLE tbl12 RENAME COLUMN a TO e; ERROR 3108 (HY000): Column 'a' has a generated column dependencyThe column to be renamed is referenced by a partitioning expression. Modifying the column name is not supported, and an error will be returned upon execution.
obclient> ALTER TABLE tbl12 RENAME COLUMN c TO e; ERROR 3855 (HY000): Column 'c' has a partitioning function dependency and cannot be dropped or renamed.The column to be renamed is referenced by a
CHECKconstraint. Modifying the column name is not supported, and an error will be returned upon execution.obclient> ALTER TABLE tbl12 RENAME COLUMN d TO e; ERROR 3959 (HY000): Check constraint 'd_check' uses column 'd', hence column cannot be dropped or renamed.The column to be renamed is referenced by a function-based index. Modifying the column name is not supported, and an error will be returned upon execution.
DROP TABLE IF EXISTS tbl12; obclient> CREATE TABLE tbl12(i INT, INDEX ((i+1))); Query OK, 0 rows affected obclient> ALTER TABLE tbl12 RENAME COLUMN i TO j; ERROR 3837 (HY000): Column 'i' has a functional index dependency and cannot be dropped or renamed.The column to be renamed is referenced by a view. The
RENAME COLUMNstatement will execute successfully, but an error will be returned when querying the view. In this case, you must manually modify the view definition.obclient> CREATE TABLE tbl13(a INT); Query OK, 0 rows affected obclient> CREATE VIEW v1 AS SELECT a + 1 FROM tbl13; Query OK, 0 rows affected obclient> SELECT * FROM v1; Empty set obclient> ALTER TABLE tbl13 RENAME COLUMN a TO b; Query OK, 0 rows affected obclient> SELECT * FROM v1; ERROR 1356 (42S22): View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use themThe column to be renamed is referenced by a stored procedure. The
RENAME COLUMNstatement will execute successfully, but an error will be returned when you call the stored procedure. In this case, you must manually modify the stored procedure definition.obclient> CREATE TABLE tbl14(a INT); Query OK, 0 rows affected obclient> CREATE PROCEDURE proc() SELECT a + 1 FROM tbl14; Query OK, 0 rows affected obclient> CALL proc(); Empty set obclient> ALTER TABLE tbl14 RENAME COLUMN a TO b; Query OK, 0 rows affected obclient> CALL proc(); ERROR 1054 (42S22): Unknown column 'a' in 'field list'
Change the column store attribute of a table
Run the following statement to create a table named
tbl1.CREATE TABLE tbl1 (col1 INT PRIMARY KEY, col2 VARCHAR(50));Convert the
tbl1table to a hybrid row-column store table and then delete the hybrid row-column store attribute.ALTER TABLE tbl1 ADD COLUMN GROUP(all columns, each column);ALTER TABLE tbl1 DROP COLUMN GROUP(all columns, each column);Convert the
tbl1table to a column store table and then delete the column store attribute.ALTER TABLE tbl1 ADD COLUMN GROUP(each column);ALTER TABLE tbl1 DROP COLUMN GROUP(each column);
Modify the Skip Index attribute of a column
Run the following statement to create a table named test_skidx.
CREATE TABLE test_skidx(
col1 INT SKIP_INDEX(MIN_MAX, SUM),
col2 FLOAT SKIP_INDEX(MIN_MAX),
col3 VARCHAR(1024) SKIP_INDEX(MIN_MAX),
col4 CHAR(10)
);
Modify the Skip Index attribute of the
col2column in thetest_skidxtable to theSUMSkip Index type.ALTER TABLE test_skidx MODIFY COLUMN col2 FLOAT SKIP_INDEX(SUM);Set the Skip Index attribute of a new column to
MIN_MAXSkip Index type after the table is created. Add theMIN_MAXSkip Index attribute to thecol4column in thetest_skidxtable.ALTER TABLE test_skidx MODIFY COLUMN col4 CHAR(10) SKIP_INDEX(MIN_MAX);Drop the Skip Index attribute of a column after the table is created. Drop the Skip Index attribute of the
col1column in thetest_skidxtable.ALTER TABLE test_skidx MODIFY COLUMN col1 INT SKIP_INDEX();or
ALTER TABLE test_skidx MODIFY COLUMN col1 INT;
Modify table attributes
Disable the persistent macroblock-level Bloom filter for the table tb.
ALTER TABLE tb SET enable_macro_block_bloom_filter = False;