INSERT keyword
INSERT
ingests selected data into a database table.
#
SyntaxInserting values directly or using sub-queries:
Inserting using sub-query alias:
#
DescriptionInserting values directly or using sub-queries:
VALUE
: Directly defines the values to be inserted.SELECT
: Inserts values based on the result of a SELECT query
Setting sub-qeury alias:
WITH AS
: Inserts values based on a subu-query, to which an alias is given by using WITH.
Parameter:
batch
expects abatchCount
(integer) value defining how many records to process at any one time.
#
Examplesnote
Columns can be omitted during INSERT
in which case the value will be NULL
#
Inserting query resultsThis method allows you to insert as many rows as your query returns at once.
Using the WITH
keyword to set up an alias for a
SELECT
sub-query:
#
Parameters for QuestDB 6.5.5 and earlier versionsnote
Deprecated content
This section applies to QuestDB 6.5.5 and earlier versions. From QuestDB 6.6 onwards, the database adjusts relevant settings automatically and provides maximum ingestion speed.
Inserting values directly or using sub-queries:
Inserting using sub-query alias:
The commitLag
parameter may be provided to optimize INSERT AS SELECT
or
WITH AS
queries when inserting
out-of-order records into an ordered
dataset:
commitLag
expects alagAmount
with a modifier to specify the time unit for the value (i.e.20s
for 20 seconds). The following table describes the units that may be used:unit description us microseconds s seconds m minutes h hours d days