oracle 去重
发布日期:2025-04-29 13:21:42
浏览次数:19
分类:精选文章
本文共 1988 字,大约阅读时间需要 6 分钟。
Oracle ???????
? Oracle ????????????????? SQL ?????????????????????????????????????????????
1. ??????
?????????????????????? SQL ???
delete from twhere rowid not in (select min(rowid) from t group by null);
????????????? rowid ?????????????????????????????????????????
2. ????
????????????????????????????????????
-- ???????insert into t_back (select distinct mobile from t)-- ????drop table t-- ?????????rename t_back to t;
?????????????????????????????????????????????????????
3. ?????
???????????????????????? SQL ???
-- ???1???2????????select field1, field2, count(*) from tgroup by field1, field2having count(*) > 1where field3 = 'value';-- ????1???2?????delete from t awhere (select field1, field2 from t_b group by field1, field2 having count(*) > 1)
4. ?????
????????????????????????????
-- ???????????create table t_temp as(select field1, field2, max(rowid) as dataid from tgroup by field1, field2);-- ????1???2?????delete from t awhere (select field1, field2 from t_temp);
5. ??????
???????rowid????????????????
-- ???? `rowid`select max(b.rowid) from t bwhere a.field1 = b.field1 and a.field2 = b.field2;-- ?? `rowid` ?????????delete from t awhere a.rowid != (select max(b.rowid) from t bwhere a.field1 = b.field1 and a.field2 = b.field2);
6. ???????
???????????????????????
-- ????????????insert into t_back (select * from t);-- ????drop table t;-- ??????create table t as select * from t_back;
7. ????
?????????????????? SQL ???
-- ??????delete from twhere column_name is null;
8. ??????
???????????????????
-- ??????delete from t awhere a.rowid in (select rowid from t_b group by null order by rowid);
9. ?????
?????????????????
-- ?????? `rowid` ???create table t_optimized as(select a.rowid, a.* from t agroup by a.rowid);-- ????drop table t;-- ?????????rename t_optimized to t;
10. ????
????????????????????????
-- ?????????insert into t_new (select * from t);-- ????drop table t;-- ?????????rename t_new to t;
?????????????????? Oracle ??????????????????????????????????
发表评论
最新留言
关注你微信了!
[***.104.42.241]2026年06月21日 18时58分21秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!