In SQL, we store data using two statements (usually):
INSERT INTO and
UPDATE. The first is used when you're adding data to a table, and the second is used to update data that already exists. There's also a variant that permits the merging of data: data that doesn't exist is added, and data that does exist is updated. Various SQL database servers do this differently, but SQLite uses
The snippets in this section are located at
snippets/08/ex4-insert-data/ in the code package of this book. When using the interactive snippet playground, select 8: Web SQL Database and Example 4.
INSERT INTO statement looks as follows:
INSERT [OR REPLACE] INTO tableName ( fieldName [, ...] ) VALUES ( values ...