INSERT inserts new rows into the specified table. The syntax below inserts a single row into the table. (An alternative syntax is described later in this section.)

INSERT INTO table_name [(column_name [, column_name...])]
VALUES (value [, value...])


Each value specified in the VALUES clause must be the appropriate data type for its respective column in the column_name list. For columns not included in the column_name list, a NULL value is placed in that field, unless a default value was specified during table creation, in which case the default value is used.

INSERT INTO customers (customerid, organizationname) VALUES (123, "John Smith")

If the column_name list is not included in the statement, then the VALUES list must contain a value for every column in the table. The VALUES list must be ordered by column number. If CREATE TABLE was used to create the table, then the order of the columns is the same as used in the CREATE TABLE statement. Or, for any SQL table, SQL-DISPLAY-TABLE displays the columns in order.

An alternative syntax inserts zero to many rows into the table based on the results of the select_statement.

INSERT INTO table_name (column_name [, column_name...]) select_statement


The results of the select_statement are re-vectored into new rows with columns specified by the column_name list. If a column in the specified table corresponds to the item-ID of the underlying D3 file, that column must be included in the column_name list.

INSERT INTO temp (id, name) SELECT customerid, organizationname FROM customers

In cases where nested tables are involved, an INSERT operation creates only rows for the nested level specified by the table definition. The parent row must be present before inserting rows in the corresponding child table. It is not valid to insert a row with a null controlling column. The controlling column is the primary key column, or the first column specified in the CREATE TABLE statement if no primary key is indicated.