INSERT keyword
INSERT
ingests selected data into a database table.
#
SyntaxInserting values directly or using sub-queries:
Inserting using sub-query alias:
#
Descriptionnote
If the target partition is
attached by a symbolic link,
the partition is read-only. INSERT
operation on a read-only partition triggers
a critical-level log in the server, and the insert is a no-op.
Inserting 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-query alias:
WITH AS
: Inserts values based on a sub-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.
#
ExamplesInserting all columns
Bulk inserts
Specifying schema
note
Columns can be omitted during INSERT
in which case the value will be NULL
Inserting only specific columns
#
Inserting query resultsThis method allows you to insert as many rows as your query returns at once.
Insert as select
Using the WITH
keyword to set up an alias for a
SELECT
sub-query:
Insert with sub-query