--Create a table
The first way
CREATE TABLE T_hui (
ID integer,//
Name text,
Sex text,
The first parameter is the name of the field to be created, and the second parameter is the type of the field
)
The second way
CREATE TABLE T_hui (
ID integer,//PRIMARY KEY autoincrement//set ID as primary key, and self-increment
Name text, unique//unique represents the value of the field can only be unique, cannot have duplicates
Sex text, NOT null default value//NOT NULL means cannot be null, default 20 means 20
The first parameter is the name of the field to be created, and the second parameter is the type of the field
)
--Inserting data
INSERT into T_hui (name,age,sex) VALUES (' Yes ', 18, ' parent ')//Add data to the specified field fields
INSERT into T_hui values (' Yes ', 18, ' parent ')//Add data to all fields, add several values in several fields, or you will get an error
--Modify data
Update T_hui Set name = ' Whitney ', age = 20//Syntax UPDATE t_hui set field 1 = ' Whitney ', field 2 = 20
--Delete data
Delete from T_hui//delete all data in table
Delete from T_hui where name = ' Little Dragon Girl '//Specify delete T_hui table inside Name field for little Dragon Girl data
--Sort Query
Select from T_hui order BY age//Query the data for age in the T_hui table, and sort them in ascending order, Desc is descending
--Summation
Select AVG (age) from T_hui//averaging data for age in T_hui table
Select Max (age) from T_hui//MAX T_hui data for age in table
Select age from T_hui where age in (1,3,4,5,67,7)//Querying Multiple values
--like operator
Select from T_hui where name '% Megumi '//filter data at the end of the benefit
Select from T_hui where name '% Megumi% '//filter data with Benefits
Select from T_hui where name ' Megumi% '//filter data beginning with preference
--Paged Query
Select from T_hui limit 0,8//starting from 0 queries, the number of queries is 8,
SELECT * from T_hui P joins T_tao s on s.id = p.id//union query
Join is the union of two tables together, on is the ID of the Union query
Android Advanced-sql language