Show TOC

INSERT StatementLocate this document in the navigation structure

The INSERT statement is used to insert values into a single database table.

            <insert statement> ::= INSERT INTO <table name> <insert column list> <insert source>.

<insert source> ::= VALUES '(' <value> ( ',' <value> )* ')'
                            | <query specification>.

<value> ::= <value expression> 
                | <dynamic parameter specification>
                | NULL.

<insert column list> ::= '(' <column name> ( ',' <column name> )* ')'.

         
Note

In Open SQL the <insert column list> is not optional.

Note

You cannot specify string literals as values for CLOB columns. Hex literals, date literals, time literals and timestamp literals are not supported in Open SQL.

Examples

Sample Code
                  INSERT INTO employees (employee_id, employee_name) 
              VALUES (4711, 'John Smith')

               

Inserting Values . A new row is inserted into the table employees with the values 4711 and 'John Smith' for the columns employee_id and employee_name respectively.

Sample Code
                  INSERT INTO well_paid_employees (employee_id, salary)
             SELECT employee_id, salary 
                            FROM employees 
                            WHERE salary > ? 

               

Inserting the Result of a Query. The employee_id and the salary of all employees from table employees with a salary exceeding a certain value are inserted into the table well_paid_employees .