第1个回答 2014-10-29
SQL> select * from t;
ID
----------
1
1
2
2
2
3
4
4
8 rows selected.
SQL> select rowid rid,id from t;
RID ID
------------------ ----------
AAAVveAAHAAAAXFAAA 1
AAAVveAAHAAAAXFAAB 1
AAAVveAAHAAAAXFAAC 2
AAAVveAAHAAAAXFAAD 2
AAAVveAAHAAAAXFAAE 2
AAAVveAAHAAAAXFAAF 3
AAAVveAAHAAAAXFAAG 4
AAAVveAAHAAAAXFAAH 4
8 rows selected.
SQL> delete from t where rowid in (select rowid rid from (select row_number() over (partition by id order by id) rn,id from t) where rn<>1);
4 rows deleted.
SQL> select rowid,id from t;
ROWID ID
------------------ ----------
AAAVveAAHAAAAXFAAA 1
AAAVveAAHAAAAXFAAC 2
AAAVveAAHAAAAXFAAF 3
AAAVveAAHAAAAXFAAG 4本回答被提问者和网友采纳