- MERGE INTO CRPROPTREND T1 USING DUAL T2
- ON (T1.URIMD5="abc")
- WHEN MATCHED THEN
- INSERT VALUES(...)
- WHEN NOT MATCHED THEN
- UPDATE SET ...;
- -- This query is not editable, but generally faster
- Select
- URIMD5,
- count(*)
- from RUNPPV.CRPROPTREND
- group by
- URIMD5
- having count(*) > 1
- -- This query is editable, but generally slower
- Select A1.*, A1.rowid
- from RUNPPV.CRPROPTREND A1
- where exists (Select 'x' from RUNPPV.CRPROPTREND A2
- where A1.URIMD5 = A2.URIMD5
- and A1.ROWID <> A2.ROWID)
- -- To delete all but one of each duplicate row,
- -- change the first line to 'Delete'
- -- and change the '<>' to '>' (keeps first duplicate)
- -- or '<' (keeps last duplicate)
本文探讨了使用SQL进行数据处理的方法,包括如何利用MERGE语句高效更新数据,以及两种查询重复记录的不同方式:一种是非编辑型查询,速度较快;另一种是可编辑型查询,虽然速度较慢但更灵活。通过这些技巧可以更好地管理和优化数据库。

2055

被折叠的 条评论
为什么被折叠?



