--数据修改与删除
--语法
--update 表名 set 字段1=值1,字段2=值2 where 条件
--调整工资每个人加薪1000元
update People set PeopleSalary=PeopleSalary+100
---将员工编号为7的人加薪50
update People set PeopleSalary=PeopleSalary+500 where PeopleId=7
--将软件部(部门编号为1)人员工资低于7000调整为9100
update People set PeopleSalary=9100 where DepartmentId =1 and PeopleSalary<7000
--修改刘备的工资是以前的1.5倍并把刘备地址改为北京
update People set PeopleSalary=PeopleSalary*1.5,PeopleAddress='北京' where PeopleName='刘备'
--删除-------------
--语法:
--delete from 表名 where 条件
--删除员工表的所有记录
delete from People
--删除本部门编号为5中工资大于9000的人
delete from People where DepartmentId=5 and PeopleSalary>9000
--关于删除(drop,truncate.delete)
drop table People --删除表对象
truncate table People --删除数据(清空数据)
delete from People --删除数据
---truncate和delete区别
--truncate清空所有数据不可以有条件,delete可以删除所有数据也可以带条件
-- 假设自动编号为1,2,3,4,5
--使用truncate清空数据之后再添加数据,编号仍然是1,2,3,4
--使用delete删除数据,数据自动编号将永远不存在
--如果使用delete删除了所有数据之后添加数据,编号变成6,7,8,9,10
sql sever 修改数据和删除数据
最新推荐文章于 2024-06-23 19:15:26 发布