INSERT

Insert records into a table

Synopsis:

 INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] 
   VALUES(value-list) | 

 INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] 
   select-statement 

Description:

The INSERT statement comes in two basic forms. The first form (with the VALUES keyword) writes a single new row in an existing table. If column-list is not specified, then the number of values must match the number of columns in that table. If column-list is specified, then the number of values must match the number of specified columns. Table columns that do not appear in the column list are filled with the default value, or with NULL if no default value is specified.

The second form of the INSERT statement takes its data from a SELECT statement. The number of columns in the result of the SELECT must match the number of columns in the table if no column list is specified, or it must match the number of columns named in the column list. A new entry is made in the table for every row of the SELECT result. The SELECT may be simple or compound. If the SELECT statement has an ORDER BY clause, the ORDER BY is ignored.

The optional conflict-algorithm parameter lets you specify an alternative constraint conflict-resolution algorithm to use during this one command; see ON CONFLICT for additional information. For compatibility with MySQL, the parser allows the use of the single keyword REPLACE as an alias for INSERT OR REPLACE.