All Products
Search
Document Center

Tablestore:Update attribute columns of a mapping table

Last Updated:Apr 29, 2026

Run the ALTER TABLE statement to add or remove attribute columns from an existing mapping table.

Note

For more information, see Update attribute columns of mapping tables.

Prerequisites

Usage notes

  • You can execute the ALTER TABLE statement to update an attribute column in only a mapping table that is created by executing the CREATE TABLE statement. You cannot execute the ALTER TABLE statement to update an attribute column in a mapping table that is automatically created for a table by executing the DESCRIBE statement.

  • You can add or remove only one attribute column in a mapping table by executing the ALTER TABLE statement. If you want to add or remove multiple attribute columns in a mapping table, you can execute the ALTER TABLE statement multiple times.

  • You can execute the ALTER TABLE statement to update only the schema of a mapping table. The schema of the Tablestore table for which the mapping table is created is not updated.

  • You cannot execute the ALTER TABLE statement to add or remove the primary key columns in a mapping table.

  • After you execute the ALTER TABLE statement, the SQL engine asynchronously refreshes the mapping table. Up to 30 seconds are required to complete the refresh. During the refresh period, the column that you added may not be returned when you perform the operations that are supposed to return all columns.

Parameters

Parameter

Description

query

The SQL statement. Configure this parameter based on the required feature.

Examples

  • Add an attribute column to a mapping table

    The following example adds a colvalue column of the BIGINT type to a mapping table named exampletable:

    def alter_table_add_column(client):
        query = 'alter table exampletable add column colvalue bigint'
        client.exe_sql_query(query)
    
  • Remove an attribute column from a mapping table

    The following example removes the colvalue column from a mapping table named exampletable:

    def alter_table_drop_column(client):
        query = 'alter table exampletable drop column colvalue'
        client.exe_sql_query(query)
    
Note

Remove attribute columns that are no longer needed before adding new ones to meet your business requirements.

FAQ

References

  • To accelerate SQL data queries and computing, you can create a secondary index or a search index. For more information, see Index selection policy and Computation pushdown.

  • After updating attribute columns, use the SELECT statement to query and analyze data. For more information, see Query data.

  • To view the description of a table, use the DESCRIBE statement. For more information, see Query information about tables.

  • To delete a mapping table that is no longer needed, use the DROP MAPPING TABLE statement. For more information, see Delete mapping tables.

  • To view index information for a table, use the SHOW INDEX statement. For more information, see Query index information about tables.

  • To list mapping tables in the current database, use the SHOW TABLES statement. For more information, see Query the names of tables.