sqlite 基本知识与使用

字段:
记录:
外键:别的表的主键
主键:唯一标识一条记录,不能有重复值
 
 
 
 
 
 
数据类型:null、 integer、 real -- 实型、 text、 blob--二进制
 
// 创建表的语法
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 的数据类型包括:

posted @   LiuZX_贤  阅读(195)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示