Show TOC

Syntax documentationINSERT Statement Locate this document in the navigation structure

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

Syntax Syntax

  1. <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> )* ')'.
    
End of the code.

Note Note

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

End of the note.

Note 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.

End of the note.
Examples

Example Example

  1. INSERT INTO employees (employee_id, employee_name) 
                  VALUES (4711, 'John Smith')
    
End of the code.

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.

Example Example

  1. INSERT INTO well_paid_employees (employee_id, salary)
                 SELECT employee_id, salary 
                                FROM employees 
                                WHERE salary > ? 
    
End of the code.

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.