【DataBase】【DML:数据操作语句】【第五天】

贡献作者 -【XJDomain】
博客XJ:  https://my.oschina.net/shengbingli/blog
GitHub直播地址https://github.com/lishengbing/XJDomainLive

1:插入语句:insert

-- 插入数据
-- insert into t_stu (name, age, score) values ('付小婕', 30, 80)

 

 

2:更新语句:update

-- 更新数据
-- update t_stu set age = 30 where id > 3

格式:
update 表名 set 字段1 = 值1,字段2 = 值2,字段3 = 值3

 

 

3:删除数据:delete

格式:
delete from 表名

-- 删除数据
-- delete from t_stu where age is 180
-- delete from t_stu where name = '李胜兵1'

 

4:条件语句:
   1:如果只想更新或者删除某些固定的记录,那就必须在DML语句后加上一些条件

条件语句的常见格式:
 1:where 字段 = 值
 2:where 字段 is 值
 
 3:where 字段 != 值
 4:where 字段 is not 值

 5:where 字段 > 值
 6:where 字段1 = 值1 and 字段2 > 值2
 7:where 字段1 = 值 or 字段2 = 值

事例:


-- 删除条件判断:名字是李胜兵,并且成绩小于80分的
-- delete from t_stu where name = '李胜兵' and score < 80


-- 删除条件判断:名字不是付小婕 或者 年龄不是20岁的删除
-- delete from t_stu where name is not '付小婕1' or age is not 20

 

转载于:https://my.oschina.net/shengbingli/blog/847194

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值