# 1. Create table¶

## 1.1. Synopsis¶

CREATE TABLE [ IF NOT EXISTS ] <table_name> ( [
{ <column_name> <data_type> }
[, ... ]
] )
[ SHARD_SIZE [=] <duration> ]


## 1.2. Description¶

CREATE TABLE will create a new table in a QuasarDB cluster with the specified schema. A special timestamp column is automatically created, which is what new data will be indexed on. If table_name already exists, CREATE TABLE will fail, unless IF NOT EXISTS is specified, in which case it will succeed and keep the original table intact.

## 1.3. Parameters¶

table_name

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

column_name

The name of a column to be created in the new table. 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(<symbol_table_name>).

duration

The size (as time duration) of a single shard (bucket). The syntax is described in section Durations.

## 1.4. Examples¶

Create a table with only a single column:

CREATE TABLE example (my_int INT64)


Create a table with only a single symbol column:

CREATE TABLE example (my_int SYMBOL(my_symbol_table))


Create a table with multiple columns:

CREATE TABLE example (my_int INT64, my_double DOUBLE, my_blob BLOB, my_ts TIMESTAMP, my_symbol SYMBOL(my_symtable), my_string STRING)


Create a table with a custom shard size:

CREATE TABLE example (my_double DOUBLE) SHARD_SIZE = 1hour 2min 3s


Creates the table as specified if it does not exists, leaves the existing table untouched if it does exist:

CREATE TABLE IF NOT EXISTS example (my_int INT64)