小伍学数据库day14

Part1:
insert into 表名()value()
1、
insert into beauty(id,name,sex,borndate,phone,photo,boyfriend_id)
values(13,‘赵静’,‘女’,‘1996-11-20’,‘17853537973’,null,7)
2、当可以为空的一行要插入的值是null时
可以直接省去,例如
insert into beauty(id,name,sex,borndate,phone,boyfriend_id)
values(13,‘赵静’,‘女’,‘1996-11-20’,‘17853537973’,7)

修改单表的记录
update 表名
set 列 = 新值
where筛选

3、修改表
1、修改表中姓夏的人的手机号为138
update beauty
set phone=‘138’
where name like ‘夏%’
2、修改多列
update boys
set boyName=‘李现’,userCP=10
where id=2
3、修改多表
#修改张无忌的女朋友的电话
update beauty b
join boys bo on b.boyfriend_id=bo.id
set phone=‘1111’
where bo.boyName=‘张无忌’

4、删除
delete from 表名 where 筛选条件
删除整列
1)#删除手机编号最后一位为0的
delete from beauty
where phone like ‘%0’
2)删除张无忌的女朋友的信息
delete b
from beauty b
inner join boys bo
on bo.id=b.boyfriend_id
where bo.boyName=‘张无忌’
3)
truncate table 表名 删除整个表
以上两个仅仅是删除表中数据,drop 是删除表格
truncate不允许加where筛选

小伍学数据库day14小伍学数据库day14 我就要学C++ 发布了14 篇原创文章 · 获赞 0 · 访问量 143 私信 关注
上一篇:day14 14线程同步-同步方法


下一篇:day14 17线程同步-同步锁