Reprint Please specify source: http://blog.csdn.net/linglongxin24/article/details/53230842
This article is from "Dylanandroid's blog"
"Play The SQLite series" (a) Start with SQLite and regain the SQL statement
SQLite is a lightweight, embedded database that is used in Android systems. In Android development
We will inevitably use the SQLite database. Next, use a series of articles to data the SQLite database.
I. Learn about SQLite
Second, the basic SQL statement that should be mastered
- 1.CREATE table: Create a sheet
/** * CREATE TABLE * IF NOT EXISTS * 表名( * 列名 列类型(大小) 性, * 列名 列类型(大小) 属性, * 列名 列类型(大小) 属性 * ) * */CREATE TABLE IF NOT EXISTS User( id Integer primary key, name varchar not null, age Integer)
- 2.DROP table: Delete a single sheet
/** * DROP TABLE IF EXISTS 表名 */DROP TABLE IF EXISTS User
- 3.INSERT into: Insert a piece of data into a table
/** * INSERT INTO 表名 VALUES (值,值,值...) * INSERT INTO 表名(列名,列名,列名...) VALUES(值,值,值...) */INSERT INTO User VALUES (1,‘张三‘,26)INSERT INTO User(id,name,age) VALUES (1,‘张三‘,26)
- 4.UPDATE: Modify one of the data in the table
/** * UPDATE 表名 SET 字段名=字段值 WHERE 修改的条件表达式 */SET name="李四" WHERE id=2
- 5.DELETE from: Delete A single piece of data from a table
/** * DELETE FROM 表名 WHERE 删除的条件表达式 */DELETE FROM User WHERE id=2
- 6.SELECT * FROM: Querying data in a table
/** * SELECT * FROM table name where query conditional expression GROUP by Group field order by Sort field * SELECT field name from table name where query conditional expression GROUP BY field of the group order by sort field * /SELECT* from UserSELECT* from User WHEREId=2SELECTName,age from User WHEREAge> -SELECTName,age from User WHEREAge between -ADN +SELECTName,age from User WHEREName like "Light"SELECTName,age from User WHEREName is NULLSELECTName,age from User ORDER byAge
"Play The SQLite series" (a) Start with SQLite and regain the SQL statement