Table Of Contents

6.3. Insert

6.3.1. Synopsis

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

6.3.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.

6.3.3. Parameters

The name of the table to be created. Can be alphanumeric, but is not allowed to start with a number.
The name of the column to insert the data to.
The value to insert into the resprective column. The format of the valuedata needs to match the type of the column, otherwise an error will be thrown.
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.

6.3.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)
6.2. Drop table
Next arrow_forward
6.4. Select