The INSERT statement creates new rows in a
table.Syntax
<insert_statement> ::=
INSERT [INTO] <table_name> [(<column_name>,...)] VALUES (<insert_expression>,...) [<duplicates_clause>]
| INSERT [INTO] <table_name> [(<column_name>,...)] <query_expression> [<duplicates_clause>]
| INSERT [INTO] <table_name> SET <set_insert_clause>,... [<duplicates_clause>]
<insert_expression> ::= <extended_expression> | <subquery>
table_name, column_name, extended_expression, duplicates_clause, subquery query_expression, set_insert_clauseExplanation
The table name must denote an existing base table, view table (see
Table), or a synonym.If column names or a SET INSERT clause are specified, all of the specified column names must be columns in the table. If the table was defined without a key (i.e. if the SYSKEY column is created internally by the database), the SYSKEY column must not occur in the sequence of column names or in a SET INSERT clause. A column must not occur more than once in a sequence of column names or in more than one SET INSERT clause.
The user must have the INSERT privilege for the table identified by the table name. If the table name identifies a view table, even the owner of the view table may not have the INSERT privilege because the view table cannot be changed.
A specified column (identified by
column name or the column name in the set_insert_clause) is a target column. Target columns can be specified in any order.Further information
If a QUERY expression is specified in the INSERT statement, none of the LONG columns may be a target column.
In the case of the INSERT statement, the third entry of SQLERRD in the SQLCA is set to the number of inserted rows.
If errors occur while inserting rows, the INSERT statement fails, leaving the table unmodified.