Http://www.runoob.com/sqlite/sqlite-insert.html
SqliteInsert Statement
The INSERT into statement for SQLite is used to add new rows of data to a table in the database.
Grammar
The INSERT into statement has two basic syntaxes, as follows:
INSERT into table_name (column1, Column2, Column3,... columnn)] VALUES (value1, value2, value3,... Valuen);
Here, Column1, Column2,... ColumnN is the name of the column in the table where you want to insert the data.
If you want to add values for all the columns in the table, you can also not need to specify the column names in the SQLite query. However, make sure that the order of values is consistent with the order of the columns in the table. The INSERT into syntax for SQLite is as follows:
INSERT into table_name VALUES (VALUE1,VALUE2,VALUE3,... Valuen);
Instance
Suppose you have created the company table in Testdb.db, as follows:
Sqlite> CREATE TABLE Company ( ID INT PRIMARY KEY isn't null, NAME TEXT not null, age int< C7/>not NULL, ADDRESS CHAR (+), SALARY REAL);
Now, the following statement creates six records in the company table:
INSERT INTO Company (id,name,age,address,salary) VALUES (1, ' Paul ', +, ' California ', 20000.00); insert INTO company (Id,na Me,age,address,salary) VALUES (2, ' Allen ', +, ' Texas ', 15000.00); INSERT into company (id,name,age,address,salary) VALUES (3, ' Teddy ', ' Norway ', ' 20000.00 '); INSERT into company (id,name,age,address,salary) VALUES (4, ' Mark ', +, ' rich- Mond ', 65000.00); insert into company (id,name,age,address,salary) VALUES (5, ' David ', +, ' Texas ', 85000.00); INSERT INTO Company (Id,name,age,address,salary) VALUES (6, ' Kim ', +, ' South-hall ', 45000.00);
You can also use the second syntax to create a record in the company table, as follows:
INSERT into company VALUES (7, ' James ', +, ' Houston ', 10000.00);
All of the above statements will create the following records in the company table. The next chapter teaches you how to display all of these records from one table.
ID NAME age ADDRESS SALARY---------- ---------- ---------- ---------- -------- --1 Paul California 20000.02 Allen Texas 15000.03 Teddy Norway 20000.04 Mark rich-mond 65000.05 David Texas 85000.06 Kim south-hall 45000.07 James Houston 10000.0
Use one table to populate another table
You can populate data into another table by using a SELECT statement on a table that has a set of fields. Here's the syntax:
INSERT into First_table_name [(Column1, Column2, ... columnn)] SELECT column1, Column2, ... columnn from second_ TABLE_NAME [WHERE condition];
SQLite using tutorial 8 Insert statement