INSERT Statement

The INSERT statement is an example of DML (Data Manipulation Language). With INSERT, you are adding data to a table in the database, but you are not changing the structure of the data in any way. The database still contains the same number of tables, and the tables still contain the same number of columns. (Compare this with the CREATE statement, which creates the table, but does not insert data into the table.)


The following is a general syntax statement for INSERT

INSERT INTO <tablename> [(field-list)]
VALUES (<values-list>)

where ...

tablename is the name of the table where you are inserting data

field-list is an optional list of fields to which you want to assign values. This list must be written according to the following syntax:

<field-name> [,<field-name] ... 

Omitting this list specifies all the fields of the table, using the same order as they are defined.

values-list is a list of literals. The values of these literals are assigned to the fields specified in <field-list>, according to the order in which they are listed. For this reason, the number of elements of both lists must be equal. At the same time, the value of the literal must be compliant with the type of field (alphanumeric, numeric, etc.) used in the table definition.

value-list has the following format:

<literal> [,<literal>] ... 



With this statement, the program inserts values into the columns of the customer table. See Host Variables for a general introduction to host variables and Host Variables for an example using host variables.