Sqlite3 changes in Database upgrade scenarios.
1, if the version of the database to be upgraded is higher, copy the contents of the same field from the lower version database as the new database, and the other fields are created by default values. A->b->c This version-by-edition upgrade, each version upgrade corresponding to a piece of code. If you upgrade to a lower version of the database, delete the database altogether and rebuild.
2, directly compared to the currently running database version, and the latest version of the database to be upgraded (A->C), the same fields are saved, the different fields are directly upgraded by default. This can be upgraded back and forth, as much as possible to save more fields of content.
The table table is created, and after the INSERT statement (inserted by row), if no values are inserted, the tables are updated according to Default_value
Create table if NOT EXISTS table_name (item1_name item1_type default default_value, item2_name item2_type default Default_v Alue,...);
Create a table and copy the contents of the other table directly.
Create table Table1_name as select Item1_name,item2_name,.... from Table2_name
Insert the value of the table2 into the row of the Table1 in line
Insert into Table1_name (Item1_name, Item2_name ...) select Item1_name, Item2_name ... from table2_name
Delete a table
Drop table IF exists table_name
Renaming a table
Alter table Table1_name Rename to Table2_name
Brief application of Sqlite3 database