sqlite 基本知识与使用
字段:
记录:
外键:别的表的主键
主键:唯一标识一条记录,不能有重复值
create table Student(ID integer primary key,name text,sex text,age text,hobby text,t_id integer)
注:create[创建] tabel[表格]Student[表格名称](ID integer primary key,)
// 添加数据的语法
insert into Student(name,sex,age,hobby,t_id)
values('jobs','男','26','Apple','1')
// 更新数据的语法
update Student set hobby = '慈善' where ID = 2
// 删除数据
delete from Student where ID = 2
//查询语句
select * from Student
select name,age from Student
//查询学号为1的学生的姓名
select name from Student where ID = 1
//模糊查找
select name from Student where name like '%C%'('C%'、‘%C’)
//查询我表中有多少行数据?
select count(*) from Student
//别名
select count(ID) as count from Student
//--多表查询--
//创建多一个叫Teacher表
create table Teacher(ID integer primary key,name text)
insert into Teacher(name)
values('tt')
//多表查询
select Student.name,Teacher.name
from Student,Teacher
where Student.t_id = Teacher.ID and Student.ID = 1
//什么是事务
Join On
sqlite 的数据类型包括: