0 for numerics. The fields in the column list and the values or fields
selected must align.
See Loading Data for inserting data into a table from sources external
to the database.
INSERT INTO … VALUES
Records with literal values can be inserted into the database.INSERT INTO ... VALUES Syntax
INSERT INTO ... VALUES Example
Insert Options
The following options can be specified to modify the way data is inserted (or not inserted) into the target table.The
WITH OPTIONS clause is only valid when used within JDBC.BATCH SIZE
BATCH SIZE
Use an ingest batch size of the given number of records.The default batch size is 50,000.
ON ERROR
ON ERROR
When an error is encountered inserting a record, handle it using one of the
following modes. The default mode is
ABORT.| Mode | Description |
|---|---|
PERMISSIVE | If an error is encountered parsing a source record, attempt to insert as many of the valid fields from the record as possible; insert a null for each errant value found. |
SKIP | If an error is encountered parsing a source record, skip the record. |
ABORT | If an error is encountered parsing a source record, stop the insert process. Primary key collisions are considered abortable errors in this mode. |
ON CONFLICT
TheON CONFLICT clause controls the behavior when an inserted record
conflicts with an existing record on the specified columns. Use
DO NOTHING to silently discard the conflicting record, or DO UPDATE SET
to update the existing record with new values.
The
ON CONFLICT clause is only valid when used within an
/execute/sql call.DO UPDATE SET clause, the special EXCLUDED reference
provides access to the values of the record that was proposed for insertion.
INSERT INTO ... VALUES ... ON CONFLICT Example
INSERT INTO … SELECT
Records that are the result set of a query can be inserted into the database.INSERT INTO ... SELECT Syntax
INSERT INTO ... SELECT Example
ON CONFLICT clause can also be used with INSERT INTO ... SELECT.
See ON CONFLICT for details.
ON CONFLICT
TheON CONFLICT clause controls the behavior when an inserted record
conflicts with an existing record on the specified columns. Use
DO NOTHING to silently discard the conflicting record, or DO UPDATE SET
to update the existing record with new values.
The
ON CONFLICT clause is only valid when used within an
/execute/sql call.DO UPDATE SET clause, the special EXCLUDED reference
provides access to the values of the record that was proposed for insertion.
INSERT INTO ... SELECT ... ON CONFLICT Example
Upserting
To upsert records, inserting new records and updating existing ones (as denoted by primary key), use theKI_HINT_UPDATE_ON_EXISTING_PK hint.
If the target table has no primary key, this hint will be ignored.
Upsert Example
By default, any record being inserted that matches the
primary key of an existing record in the target table will be discarded,
and the existing record will remain unchanged. The
KI_HINT_UPDATE_ON_EXISTING_PK hint overrides this behavior, favoring the
source records over the target ones.Ignoring Duplicates
To discard duplicate records (as denoted by primary key) when inserting data, use theKI_HINT_IGNORE_EXISTING_PK hint. If the target table has no
primary key or if in upsert mode (using KI_HINT_UPDATE_ON_EXISTING_PK),
this hint will be ignored.
Ignore Duplicates Example