Skip to main content

INSERT

Insert records into a table, either from values provided in the SQL command or from rows returned by a SELECT statement.

If the table does not exist or the schema does not match, the INSERT operation fails.

Insert syntax
INSERT INTO <table_name>
[ AT { REF[ERENCE] | BRANCH } <reference_name> ]
[ ( <column_name1> [, <column_name2> ...]) ]
{ <select_statement>
| VALUES (value [, value ...]) [, (value [, value ...]) ...] }

Parameters

<table_name> String

The name of the table that you want to insert data into.


AT { REF[ERENCE] | BRANCH } <reference_name> String   Optional

Specifies the reference of the table that you want to insert data into. When this parameter is omitted, the current branch is used.

REF: Identifies the specific reference.

BRANCH: Identifies the specific branch.


[ ( <column_name1> [, <column_name2> ...] ) ] String   Optional

The name of the column or columns that you want to insert data into.

  • If column names are specified, data is inserted in the given column order, and columns not listed are populated as NULL.
  • If column names are not specified, data is inserted in the column order of the table.

<select_statement> String   Optional

The query that you want to use to insert into the current table data from another table.


VALUES (value [, value ...]) [, (value [, value ...]) ...] String   Optional

The value or values that you want to insert, if you specified the names of one or more columns. You can insert one or more sets of values, each set corresponding to a record to insert into the table.

Examples

Inserts three records
INSERT INTO myTable VALUES
(21, 'Ruth Asawa', 'American, 1926–2013', 'American', 'Female', 1926, 2013, 'Q7382874', '500077806'),
(38, 'Magdalena Abakanowicz', 'Polish, 1930–2017', 'Polish', 'Female', 1930, 2017, 'Q158080', '500084577'),
(56, 'Luis Alberto Acuña', 'Colombian, 1904–1994', 'Colombian', 'Male', 1904, 1994, null, null)
Inserts three records at a table in a specified branch
INSERT INTO myTable
AT BRANCH main
VALUES
(21, 'Ruth Asawa', 'American, 1926–2013', 'American', 'Female', 1926, 2013, 'Q7382874', '500077806'),
(38, 'Magdalena Abakanowicz', 'Polish, 1930–2017', 'Polish', 'Female', 1930, 2017, 'Q158080', '500084577'),
(56, 'Luis Alberto Acuña', 'Colombian, 1904–1994', 'Colombian', 'Male', 1904, 1994, null, null)
Inserts values for a struct table
INSERT INTO struct_type VALUES (convert_from('{ x: "hi" }', 'json'))