Insert
insert into table — single and multi-value expr lists.
One Object
One object in the values list produces one row.
SQL
create table T;
insert into T ({x: 1});
select * from T;
Result
[
{ "x": 1 }
]
Two Objects
Two objects in one statement produce two rows.
SQL
create table T;
insert into T ({x: 1}, {x: 2});
select * from T;
Result
[
{ "x": 1 },
{ "x": 2 }
]
Five Objects
Five objects in one statement are all persisted.
SQL
create table T;
insert into T ({x: 1}, {x: 2}, {x: 3}, {x: 4}, {x: 5});
select * from T;
Result
[
{ "x": 1 },
{ "x": 2 },
{ "x": 3 },
{ "x": 4 },
{ "x": 5 }
]
One Multi-value
One multi-value insert persists all rows.
SQL
create table T;
insert into T ({x: 1}, {x: 2}, {x: 3});
select * from T;
Result
[
{ "x": 1 },
{ "x": 2 },
{ "x": 3 }
]
Three Single-value
Three single-value inserts produce the same table as one multi-value insert.
SQL
create table T;
insert into T ({x: 1});
insert into T ({x: 2});
insert into T ({x: 3});
select * from T;
Result
[
{ "x": 1 },
{ "x": 2 },
{ "x": 3 }
]
Values In
Values in one insert may differ in shape.
SQL
create table T;
insert into T ({x: 1, y: 2}, {x: 3});
select * from T;
Result
[
{ "x": 1, "y": 2 },
{ "x": 3 }
]
Object Rejected
A stored row must be an object; a scalar value is rejected.
SQL
create table T;
insert into T (1, 2, 3);
Expected error: schema
Values List
Values list may span multiple lines.
SQL
create table T;
insert into T (
{x: 1},
{x: 2},
{x: 3}
);
select * from T;
Result
[
{ "x": 1 },
{ "x": 2 },
{ "x": 3 }
]
Inserting Into
Inserting into an undeclared table is a static error.
SQL
create table T;
insert into Ghost ({x: 1});
Expected error: static
Empty Values
Empty values list is a no-op.
SQL
create table T;
insert into T ();
select * from T;
Result
[]
An Array
An array value as a row is rejected with a schema error (not a panic).
SQL
create table T;
insert into T ([1, 2, 3]);
Expected error: schema