I. Basic creation Operation:
CREATE TABLE IF not EXISTS t_dog (name text, age Bolb, weight real);
INSERT into T_shop (name, Left_count) VALUES (' fan ', 100);
UPDATE t_shop SET Price = 6288, Left_count = 0;
- 4. Delete data from a table
DELETE from T_shop;
DROP TABLE T_dog;
Two. Conditional statements
UPDATE t_shop SET left_count = 0 WHERE price < 1000;
DELETE from T_shop WHERE Left_count <, and price < 500;
DELETE from T_shop WHERE Left_count <, OR Price < 500;
SELECT name, Price, left_count from T_shop;
SELECT * from T_shop WHERE left_count > 80;
- aliases : SELECT name Shop_name, price as Shop_price, Left_count inventory from T_shop s;
- count: SELECT Count (*) remaining quantity from T_shop WHERE left_count > 50;
- Descending query : SELECT *from t_shop ORDER by Left_count DESC;
- default ASC: SELECT *from t_shop ORDER by Left_count DESC, price ASC;
- limit: SELECT *from t_shop limit 2, 4;
SELECT *from t_shop ORDER by Price DESC LIMIT 1, 10; ----Fetch the 2nd page with the highest price, 10 records;
- constraint : CREATE TABLE IF not EXISTS t_student (name text notnull, age integer);
- CREATE TABLE IF not EXISTS t_student (name text is not null - UNIQUE, age integer is not null);
- CREATE TABLE IF not EXISTS t_student (name text is not null - UNIQUE, age integer DEFAULT 1 NOT NULL );
- PRIMARY KEY constraint: primary key
CREATE TABLE IF not EXISTS t_class (ID integer PRIMARY KEY autoincrement, Name text not NULL UNIQUE);
INSERT into T_class (name) VALUES (' iOS ');
INSERT into T_class (name) VALUES (' andriod ');
---SQLite statement for the database