INSERT statement

Use the INSERT statement to insert one or more new rows into a table or view, or to insert one or more elements into an SQL or Informix® ESQL/C collection variable.

Syntax

(explicit id ins002) ins002 (explicit id ins004) ins004 (explicit id ins005) ins005 (explicit id ins007) ins007 (explicit id ins008) ins008 (explicit id ins009) ins009 (explicit id ins010) ins010 INSERT { INTO { { synonym | view | table } [ ( column ) ] { <VALUES Clause>[] | <EXECUTE Routine Clause>[] | <Subset of SELECT Statement> [] } | external [ ( column ) ] [ <Subset of SELECT Statement> [] ] } | [ AT position [][] ] INTO <Collection-Derived Table>[] <Field Options> [] }

Element Description Restrictions Syntax
column Column to receive new value See Specifying Columns. Identifier
external External table into which to insert data Must exist Database Object Name
field Field of a named or unnamed ROW data type Must already be defined in the database CREATE ROW TYPE statement
position Position at which to insert an element of a LIST data type Literal integer or an INT or SMALLINT type SPL variable. Literal Number
synonym, table, view Table, view, or synonym in which to insert data Synonym or view and the table to which it points must exist Database Object Name

Usage

To insert data into a table, you must either own the table or have the Insert privilege for the table (see GRANT statement). To insert data into a view, you must have the required Insert privilege, and the view must meet the requirements explained in Inserting Rows Through a View.

If the table or view has data integrity constraints, the inserted rows must meet the constraint criteria. If they do not, the database server returns an error. If the checking mode is set to IMMEDIATE, all specified constraints are checked at the end of each INSERT statement. If the checking mode is set to DEFERRED, all specified constraints are not checked until the transaction is committed.

1 Informix® extension
2 Stored Procedure Language only
3 ESQL/C only