You can execute the ALTER TABLE statement to modify a table.

The current Hologres version allows you to execute the ALTER TABLE statement to rename a table, add columns to a table, and modify properties of a table.

Rename table

  1. Synopsis
    ALTER TABLE table_name RENAME TO new_table_name;
  2. Limitation

    An error is thrown if you execute RENAME to rename a table that does not exist or rename a table to the name of an existing table.

  3. Examples
    ALTER TABLE test RENAME TO holo_test ;

Add columns

  1. Synopsis
    ALTER TABLE IF EXISTS table_name ADD COLUMN new_column_name data_type;
    ALTER TABLE IF EXISTS table_name ADD COLUMN col_add_1 data_type, ADD COLUMN col_add_2 TEXT IF NOT EXISTS col_add_2 data_type; 
  2. Examples
    ALTER TABLE IF EXISTS holo_test ADD COLUMN id int;

Alter table property

Generally, you must call the set_table_property function in the same transaction as CREATE TABLE. However, you can execute the following SQL statements independently to modify the specified properties:

call set_table_property('tbl', 'bitmap_columns', '[columnName [,...]]'); 
call set_table_property('tbl', 'dictionary_encoding_columns', '[columnName [,...]]');
call set_table_property('tbl', 'time_to_live_in_seconds', '<non_negative_literal>');
Examples
  1. To change the columns on which Hologres builds bit codes, execute the following SQL statement:
    call set_table_property('tbl', 'bitmap_columns', 'a,b');
  2. To change the dictionary encoding columns, execute the following SQL statement:
    call set_table_property('tbl', 'dictionary_encoding_columns', 'a,b');
  3. To change the time to live (TTL) of data in a table, execute the following SQL statement:
    call set_table_property('tbl', 'time_to_live_in_seconds', '86400');