1.创建表
(1)create table Students(id varchar(16),name varchar(16),score varchar(6));
(2)create table if not exists Students(id varchar(16),name varchar(16),score varchar(6));
2.删除表
drop table Students;
3.插入
(1)insert into Students values(1,'YueBuQun',75);
(2)自增形式插入:inser into WuGong(name) values('zixiashengong');
4.查看
(1)查看单个表
select * from Students;(*代表查看所有字段,可以查看单个字段)
(2)查看多个表元素
select Students.id,Students.name,WuGong.name from Students,WuGong where Students.id=WuGong.id;
(3)条件查看
select * from Students where score>75 and score<90
(4)排序查看
1)正序
select * from Students order by score;
2倒序
select * from Students order by score desc;
(4)只看两条
select * from Students limit 2;
(5)查看有多少条数据
select count(*)from Students;
(6)平均分,总和分
select sum(score)from Students;
select div(score)from Students;
5.修改
update Students set score=90 where id=1;
6.删除
delete from Students where id=3;
7.设置主键和唯一键
(1)create table if not exists WuGong(id INTEGER primary key autoincrement,name TEXT unique);
(2)自增形式插入:inser into WuGong(name) values('zixiashengong');