sqlite 3基本使用方法

1、sqlite数据库数据类型

  Integer      整型

  varchar(10)    字符数组

  float       浮点型

  double      双精度浮点型

  char(10)      字符型

  text        文本型

2、sql语法

2.1 创建表语句

  create table 表名(字段名称 数据类型 约束,字段名称 数据类型 约束......)

  create table person(id Integer primary key,name varchar(10),age Integer not null)

2.2 删除表的语句

  drop table 表名

  drop table person

2.3 插入数据

  insert into 表名(字段,字段) values(值1,值2)

  insert into person(id,age) values(1,20)

  insert into person values(2,"qwe",30)-->如果没有指定字段名称,则values中的值必须从表结构中第一个字段开始依次赋值

2.4 修改数据

  update 表名 set 字段=新值 where 修改的条件

  update person set name=“ls” where id=1

  note:不添加where表明修改表中所有的字段,修改多个字段可以用,隔开

  update person set name=“ls”,age=20 where id=1

2.5 删除数据

  delete from 表明 where 删除的条件

  delete from person where id=2

2.6 查询数据

  select 字段名 from 表明 where 查询条件 group by 分组的字段 having 筛选条件 order by 排序字段

  select * from person;               查询表person中所有的数据

  select id,name from person;            查询表person中字段为id和name 的数据

  select * from person where id=1          查询表person中id=1的数据 

  select * from person where id=1 and age>18    查询表person中id=1和age大于18的数据

原文地址:https://www.cnblogs.com/Malphite/p/8323892.html