自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

5種情況下sql server刪除數(shù)據(jù)的方法

數(shù)據(jù)庫 SQL Server
根據(jù)不同的情況,刪除SQL數(shù)據(jù)庫中的方法也有所不同,下文介紹了5種情況下sql server刪除數(shù)據(jù)的方法,希望對您能有所啟迪。

有很多種方法都可以實現(xiàn)sql server刪除數(shù)據(jù),下面就為您介紹了其中5種最常見的方法,如果您對sql server刪除數(shù)據(jù)方面感興趣的話,不妨一看。

1、查找表中多余的重復記錄,重復記錄是根據(jù)單個字段(peopleId)來判斷
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)

2、刪除表中多余的重復記錄,重復記錄是根據(jù)單個字段(peopleId)來判斷,只留有rowid最小的記錄
delete from people
where peopleId in (select peopleId from people group by peopleId   having count(peopleId) > 1)
and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)

3、查找表中多余的重復記錄(多個字段)
select * from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)

4、sql server刪除數(shù)據(jù)--刪除表中多余的重復記錄(多個字段),只留有rowid最小的記錄
delete from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)

5、查找表中多余的重復記錄(多個字段),不包含rowid最小的記錄
select * from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
 

 

 

【編輯推薦】

sql server刪除有默認值的列的方法

SQL SERVER連接失敗的解決方案

帶您了解SQL Server游標

八步輕松搞定SQL Server自動備份

SQL Server的優(yōu)點和缺點

責任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-10-22 17:26:55

SQL Server刪

2010-04-25 17:34:30

負載均衡實現(xiàn)

2010-09-02 10:15:46

SQL刪除

2010-11-10 11:42:35

SQL Server2

2010-06-30 10:55:13

SQL Server日

2010-07-13 16:07:26

SQL Server行

2010-06-28 15:27:54

SQL Server

2010-10-22 16:29:11

SQL Server刪

2015-06-29 14:11:30

網(wǎng)絡(luò)接入無線網(wǎng)絡(luò)

2010-11-10 13:28:06

SQL Server刪

2010-07-09 09:34:37

SQL Server數(shù)

2010-09-01 16:55:55

SQL刪除連接

2011-09-13 15:51:54

刪除數(shù)據(jù)庫重復行

2010-07-30 15:32:23

2010-09-28 15:46:22

SQL刪除重復記錄

2018-01-08 19:17:21

數(shù)據(jù)庫Oracle重啟

2010-11-10 13:03:15

SQL Server存

2010-11-03 13:09:14

DB2卸載方法

2010-10-20 10:19:33

sql server刪

2010-11-10 11:54:32

SQL SERVER刪
點贊
收藏

51CTO技術(shù)棧公眾號