SQLite (4)-Data modification and deletion, sorting

change the data

In SQLite used updateto modify the data existing data, can whererange clause sets the modified constraint, without using whereclause constraint updatestatement, modify the table corresponding to all types of data.

For example, Li Yi and Zhao Min in the following table both have a salary increase of 2000. At this time, we need to update the data in the table to 10000 and 12000 respectively. The wage data in the table can be modified through the update and where statements.
Insert picture description here
The implementation is as follows:
Insert picture description here
If you wheretry without using clauses to restrict the modification conditions, you will find that all the wage values ​​have been modified to the same value.
Insert picture description here

delete data

Use deletestatements in SQLite to delete existing data in the table. You can use whereclauses to set the scope of constraint modification. If you do not use whereclauses to constrain the deletestatement, all data of the corresponding type in the table will be modified.

For example, Zhao Min has resigned and needs to be deleted from the table. The realization is as follows:
Insert picture description here

Sort

Regarding sorting, order byclauses and selectsentences are combined to achieve the sorting effect. Sorting is divided into descending order (DESC) and ascending order (ASC).

For example, we now sort by the wage value in descending order, as follows:
Insert picture description here
We also use whereclauses to restrict the sorted access, for example, now it is required that age>=25, and the wage value is in descending order, as follows:

Insert picture description here

Guess you like

Origin blog.csdn.net/hzw2017/article/details/84557461