SQL Server修改表中数据的关键字是update(更新;使现代化;向…提供最新信息;给…增加最新信息)
语法
update 表名 set 字段1=值1,字段=值2 where 条件1 and 条件2
给表中所有人加工资,不需要使用where进行约束
update people set PeopleSalary=PeopleSalery+1000
用where 进行约束,注意如果字段是字符串类型,需要加上引号
--给指定人加薪,如给小陈再加3000
update people set PeopleSalary = PeopleSalary +3000 where PeopleName='小陈'
如果有多个条件去约束要修改的内容,在where的后面用and去连接,条件1、条件2
update people set PeopleSalary=15000 where DepartmentId=1 and PeopleSalary<15000
如果有多条需要修改,在要修改的列中间打上逗号
update people set PeopleSalary=PeopleSalary*2 , PeopleAddress='北京' where PeopleName='小张'
SQL Server删除表中数据的关键字是delete(删去,删除(痕迹等);消除,擦去(痕迹等))
delete from 表名
同修改一样当有多个条件时,在where后面分别列出 条件1,条件2
delete from people where DepartmentID=3 and PeopleSalary>1000