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


分享到:


相關文章: