Simple operation of SQLite database

Source: Internet
Author: User
Tags sqlite sqlite database

A SQLite introduction

SQLite is an embedded database, similar to a file system, that is with the program. and MySQL and other database programs and data separation is not the same.

Application scenario: Often used to save local configuration, similar to the local file system, so he embedded in Linux, Android, iOS and other systems, the use of the time does not need to reinstall. For example: local contacts on the phone, historical access records, etc. local data is basically saved using sqlite data.

Two-use

Create a table

Create table if not exists persion (_id integer primary key autoincrement, name text, salary real);

Query table structure sqlite_master This system table, used to store views, indexes, tables and other information

Select *from sqlite_master where type= ' table ';

Add data

Insert into person (name, salary) values (' Xiao Qiang ', 6000.0)

Fuzzy query + pagination + sorting

Select *from persion where name like '% small% ' ORDER by salarty ASC limit 0,3//ASC Ascending desc Descending

Common Party function min,max,avg,cout (*)

First group after aggregation, query the wages of the same person's information

Select *from Person where salary= (select salary from person group by salary have count (*) >1)

Create a View

Create View St as select _id,name from;

SQLite like clause: percent semicolon (%) represents 0, one or more digits or characters. An underscore (_) represents a single number or character. These symbols can be used in combination.

WHERE SALARY like ' 2_%_% '

Find any value starting with 2 with a length of at least 3 characters

Here is just the simplest record of operations, in addition to triggers, views, indexes and other related operations, can refer to the relevant information, here do not do too much elaboration

Simple operation of SQLite database

Related Article

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.