Common Set Syntax:
| INSERTINTOtable-name | 
 | 
 | 
This document covers the following topics:
For explanations of the symbols used in the syntax diagram, see Syntax Symbols.
Belongs to Function Group: Database Access and Update
The SQL INSERT statement is used to add one or more new
                       rows to a table.
               
| Syntax Element | Description | 
|---|---|
| INTO
                                       table-name |  INTO Clause: In the  See further information on
                                         | 
| column-list |  Column List: Syntax: column-name... In the  If a  If the  | 
| VALUES-clause |  Values Clause: With the  See VALUES Clause below. | 
With the VALUES clause, you insert a single row
                       into the table. Depending on whether an asterisk (*) or a
                       column-list has been specified, the
                       VALUES clause can take one of the following forms:
               
| VALUES(VIEWview-name) | 
If asterisk notation is specified, a view must be specified in
                       the VALUES clause. With the field values of this view, a new row
                       is inserted into the specified table using the field names of the view as
                       column names of the row.
               
| VALUES( | 
 | 
 | ) | 
If a column-list is specified
                       and a view is referenced in the VALUES clause, the number of items
                       specified in the column list must correspond to the number of fields defined in
                       the view within the VALUE-LIST.
               
If no column-list is specified,
                       the fields defined in the view are inserted according to an implicit list of
                       all the columns in the order they exist in the specified table.
               
Common Set Syntax:
| 
 | VALUES | 
 | 
 | 
 | ||||||||||
Extended Set Syntax:
| 
 | VALUES | 
 | 
 | 
 | ||||
| select-expression | 
 | WITH | 
 | 
 | 
 | |||
Syntax Description:
| Syntax Element | Description | |
|---|---|---|
| VIEW
                                       view-name | View Name: With the field values of this view, a new row is inserted into the specified table using the field names of the view as column names of the row. | |
| insert-item-list |  INSERT Single Row: In the  If no  The values to be specified in the
                                         See the section Basic Syntactical Items for
                                        information on  If the value  Example - INSERT Single Row: ...
INSERT INTO SQL-PERSONNEL (NAME,AGE)
  VALUES ('ADKINSON',35)
... | |
| select-expression |  INSERT Multiple Rows: This clause belongs to the SQL Extended Set. With a select-expression, you insert
                                        multiple rows into a table. The
                                        select-expression is evaluated and each row of the
                                        result table is treated as if the values in this row were specified as values
                                        in a VALUES
                                           Clause of a single-row  For further information, see Select Expressions. Example - Insert Multiple Rows: ... INSERT INTO SQL-RETIREE (NAME,AGE,SEX) SELECT LASTNAME, AGE, SEX FROM SQL-EMPLOYEES WHERE AGE > 60 ... Note: | |
| WITH
                                       RR/RS/CS |  WITH Isolation Level Clause: This clause belongs to the SQL Extended Set. This clause allows the explicit specification of the isolation level used when locating the rows to be inserted. It is only valid against DB2 databases. When used against other databases, it will cause runtime errors. | |
| CS | Cursor Stability | |
| RR | Repeatable Read | |
| RS | Read Stability | |