7. Insert#

7.1. Synopsis#

INSERT INTO <table_name> (
   $timestamp, <column_name> [, ... ]
 )
 VALUES (
   { <value> | <expression> } [, ... ]
 ) [, ...]

7.2. Description#

INSERT INTO will insert a row into an existing table. It requires the timestamp to be explicitly provided using the special column $timestamp, which should always be the first column.

Column names are matched with their values using their index. The amount of columns should always be exactly equal to the amount of values.

QuasarDB being a column-oriented database supports inserting into a subset of the columns available for a certain table. The missing values will have a NULL-value and do not incur any storage costs.

7.3. Parameters#

table_name

The name of the table which should be modified.

column_name

The name of the column which should be modified.

value

The value to insert into the respective column. The format of the valuedata needs to match the type of the column, otherwise an error will be thrown.

expression

The result of an expression which evaluates to a value. A common use case is to use now as the value for $timestamp. For more information on valid values for $timestamp, please refer to the documentation for timestamps.

7.4. Examples#

Insert a 64-bit integer:

INSERT INTO example ($timestamp, my_int) VALUES (now(), 1234)

Insert a floating point / double:

INSERT INTO example ($timestamp, my_double) VALUES (now(), 12.34)

Insert a blob string:

INSERT INTO example ($timestamp, my_blob) VALUES (now(), 'etaoin shrdlu')

Insert a timestamp:

INSERT INTO example ($timestamp, my_ts) VALUES (now(), 2018-08-01T03:00:00)

Insert a timestamp referring to a day:

INSERT INTO example ($timestamp, my_ts) VALUES (now(), 2018-01-01)

Insert a timestamp referring to a specific nanoesecond:

INSERT INTO example ($timestamp, my_ts) VALUES (now(), 2018-08-01T00:00:00.000000001Z)

Insert a row with multiple columns:

INSERT INTO example ($timestamp, my_int, my_double, my_blob, my_ts) VALUES (now(), 1234, 12.34, 'etaoin shrdlu', 2018-08-01)

Insert three rows with one 64-bit integer each:

INSERT INTO example ($timestamp, my_int) VALUES (now(), 1234), (now(), 2345), (now(), 3456)