SQL SERVER数据库中删除语句delete的用法

--删除数据的语法:
--delete from 表名 where 条件
select * from studentInfo
--删除姓名为Jim的学生信息
delete from studentInfo where stuName='Jim'
select * from studentInfo

--根据Id删除:删除学号为10006的学生信息
delete from studentInfo where stuID = 10006
select * from studentInfo

--删除年龄大于等于等于17并且小于等于20岁的学生信息(删除多条)
delete from studentInfo where stuAge >=17 and stuAge<=20
select * from studentInfo

--删除是不给任何条件或者where 1=1 代表删除所有的数据
delete from scoreInfo
delete from scoreInfo where 1=1


select * from studentInfo
select * from scoreInfo

--已知成绩表中的stuId引用学生表中的stuId ,这种情况下我们执行删除操作会出现什么结果呢
delete from studentInfo where stuID = 10000

select * from scoreInfo
--以空为条件作为删除
delete from scoreInfo where createTime is null
select * from scoreInfo


分享到:


相關文章: