ALTER-TABLE-ROLLUP

Name

ALTER TABLE ROLLUP

Description

This statement is used to perform a rollup modification operation on an existing table. The rollup is an asynchronous operation, and the task is returned when the task is submitted successfully. After that, you can use the SHOW ALTER command to view the progress.

grammar:

  1. ALTER TABLE [database.]table alter_clause;

The alter_clause of rollup supports the following creation methods

  1. Create a rollup index

grammar:

  1. ADD ROLLUP rollup_name (column_name1, column_name2, ...)
  2. [FROM from_index_name]
  3. [PROPERTIES ("key"="value", ...)]

properties: Support setting timeout time, the default timeout time is 1 day.

  1. Create rollup indexes in batches

grammar:

  1. ADD ROLLUP [rollup_name (column_name1, column_name2, ...)
  2. [FROM from_index_name]
  3. [PROPERTIES ("key"="value", ...)],...]

Notice:

  • If from_index_name is not specified, it will be created from base index by default
  • Columns in rollup table must be columns already in from_index
  • In properties, the storage format can be specified. For details, see CREATE TABLE
  1. Delete rollup index

    grammar:

  1. DROP ROLLUP rollup_name [PROPERTIES ("key"="value", ...)]
  1. Batch delete rollup index

grammar:

  1. DROP ROLLUP [rollup_name [PROPERTIES ("key"="value", ...)],...]

Notice:

  • cannot delete base index

Example

  1. Create index: example_rollup_index, based on base index (k1,k2,k3,v1,v2). Columnar storage.
  1. ALTER TABLE example_db.my_table
  2. ADD ROLLUP example_rollup_index(k1, k3, v1, v2);
  1. Create index: example_rollup_index2, based on example_rollup_index (k1,k3,v1,v2)
  1. ALTER TABLE example_db.my_table
  2. ADD ROLLUP example_rollup_index2 (k1, v1)
  3. FROM example_rollup_index;
  1. Create index: example_rollup_index3, based on base index (k1,k2,k3,v1), with a custom rollup timeout of one hour.
  1. ALTER TABLE example_db.my_table
  2. ADD ROLLUP example_rollup_index(k1, k3, v1)
  3. PROPERTIES("timeout" = "3600");
  1. Delete index: example_rollup_index2
  1. ALTER TABLE example_db.my_table
  2. DROP ROLLUP example_rollup_index2;
  1. Batch Delete rollup index
  1. ALTER TABLE example_db.my_table
  2. DROP ROLLUP example_rollup_index2,example_rollup_index3;
  1. Keywords
  1. ALTER, TABLE, ROLLUP, ALTER TABLE

Best Practice