picoSQL - Language reference manual |
Syntax: |
Format 1: INSERT INTO table-name
[(column-name [, column-name]...)] Format 2: INSERT INTO table-name [(column-name [, column-name]...)] subquery |
Purpose: |
Allows the insertion of one or more rows in a table.
|
See also: |
REPLACE, DELETE, SELECT
|
Description:
|
This command allows to insert one o more rows in the named table. Format 1 allows to insert only one row with the specified values after the VALUES clause. If the optional column names list is specified, expressions after the VALUES clause are in positional correspondance with the columns name (the first with the first, the second with the second and so on). If the columns list does not comprise all the attribute defined in the table, the value NULL is put in the missing attributes. If the optional column names list is not specified, all the attributes of the table must be specified after the VALUES clause: the corrispondence between the table attributes and the experssion is done by position. The row is inserted in an arbitrary position. Format 2 allows to get the expression to insert from a SELECT statement. Also in this case there is positional correspondance between specified attributes, or table attributes, and the result expressions from the subquery. If one or more attributes of the table are declared as SERIAL type and they contain the NULL value, they will receive a sequential number. Assigned values can be obtained using the SELECT SERIAL statement (introduced from release 2.0) on condition to use the same statement handle used for INSERT statement. |