SQLite入门

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,'uncle firefly',24);

2.4 修改数据
update 表名 set 字段=新值 where 修改条件

update persion set name='萤火虫叔叔',age=25,where _id=2;

2.5 删除数据
delete from 表名 where 删除条件

delete from person where _id=1;

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

select * from person;
select _id,name from person;
select * from person where _id=1;
select * from person where _id<>1;
select * from person where _id=1 and age>18;
select * from person where name like "%fire%";
select * from person where name like "萤火%";
select * from person where name is null;
select * from person where age between 10 and 20;
select * from person where age>18 order by _id;
    原文作者:萤火虫叔叔
    原文地址: https://www.jianshu.com/p/dea7e8c1a30a
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞