Brief application of Sqlite3 database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.