The example of this article describes the Android development of the Sqlite3 command line simple use method. Share to everyone for your reference, specific as follows:
First you need to navigate to the directory where the database is located, and then use the command sqlite3 databasename (the name of the db) to enter
Common commands:
1. Table lists the data table names below the database
2. Schema or. schema + table name gets the table structure of a whole or a single table
3. Database shows where the database is located
4. Dump displays all information about the database (including table structure, table data)
Note: You need to type the SQL statement; ...> is also typed if it appears; try, if not, CTRL + Z.
Comes with some common SQL statements:
(1) Data record filtering:
Sql= "SELECT * from data table where field name = field value order BY field name [desc]"
sql= "select * from datasheet where field name like '% field value% ' Order By field name [ DESC] "
sql=" SELECT top * from data table where field name order by field name [desc] "
sql=" SELECT * from data table where field name in (' Value 1 ', ' Value 2 ') , ' Value 3 '] "
sql=" SELECT * from data table where field name between value 1 and value 2 "
(2) Update data records:
sql= "Update data table set field name = field value where Condition expression"
sql= "update datasheet SET field 1= value 1, field 2= value 2 ... field n= value n Where Condition expression "
(3) Delete data records:
Sql= "Delete from datasheet where condition expression"
sql= "delete from data table" (delete all records from datasheet)
(4) Adding data records:
sql= INSERT into Data table (field 1, Field 2, Field 3 ...) valuess (value 1, value 2, value 3 ...)
Sql= INSERT INTO Target datasheet SELECT * from source datasheet (add a record from the source datasheet to the destination datasheet)
(5) Data record statistic function:
AVG (field name) to derive a table column average
Count (*| field name) statistics on the number of data rows or the number of data rows that have a value for a column
Max (field name) gets the maximum value of a table column
Min (field name) gets the smallest value of a table column
sum (field name) adds the value of the data bar
How to reference the above function:
Sql= "Select sum (field name) as Alias from data table where condition expression"
set Rs=conn.excute (SQL)
For more information on Android-related content readers can view the site topics: "Android Development Introduction and Advanced Course", "Android Database Operating skills summary" and "Android Control usage Summary"
I hope this article will help you with the Android program.