1. Alter table

    1. Alter table

    1.1. Synopsis

     ALTER TABLE { <entries> | <find_expression> } [, ... ] ADD
       { <column_name> <data_type> }
       [, ... ]
    
     ALTER TABLE { <entries> | <find_expression> } [, ... ] RENAME
       { <current_column_name> TO <new_column_name> }
       [, ... ]
    
    find_expression ::=
      FIND ( { <tag_expression> | NOT <tag_expression> } [ AND ... ] )
    
    tag_expression ::=
      TAG = 'tag_name'
    

    1.2. Description

    ALTER TABLE will modify one or more tables in a QuasarDB cluster by adding or renaming columns with the specified schema. The statement is transactional.

    1.3. Parameters

    table_name

    The name of the table to be modified. Can be alphanumeric, but is not allowed to start with a number.

    find_expression

    When your tables are tagged, you can use inline key/value lookups to perform your query over multiple tables. To match all tables that have the tag “stocks”, you can use FIND(tag='stocks' AND type=ts).

    column_name, current_column_name, new_column_name

    The name of a column to be added or renamed. Can be alphanumeric, but is not allowed to start with a number.

    data_type

    The data type to be associated with the column. Can be any of INT64, DOUBLE, BLOB, TIMESTAMP, STRING or SYMBOL.

    1.4. Examples

    Add a single column to an existing table:

    ALTER TABLE example ADD my_int INT64
    

    Add multiple columns to an existing table:

    ALTER TABLE example ADD my_int INT64, my_double DOUBLE, my_blob BLOB, my_ts TIMESTAMP, my_symbol SYMBOL(my_symtable)
    

    Rename a single column of an existing table:

    ALTER TABLE example RENAME my_int TO my_new_int
    

    Rename multiple columns of an existing table:

    ALTER TABLE example RENAME my_int TO my_new_int, my_double TO my_new_double
    

    Swap names of columns in an existing table:

    ALTER TABLE example RENAME column_a TO column_b, column_b TO column_a