Home > database >  ORACLE to remove duplicate data tip
ORACLE to remove duplicate data tip

Time:09-29

Preface: first your table data is less than 1 million, if more than words, I this method efficiency is low!

1. When a table has duplicate values, first of all you need to have a clear point out what you need data, and then on to heavy,
2. If you want this field is the only, you are behind the partition by combined with the field;
If you want to two fields only, in the partition by followed by the two fields;
If you want to is the only three fields combination, in the partition by followed by these three fields;
This theory only, you want a few field combination is behind the partition by combined with the several fields;
3. Choose the pattern you need to, as long as the sorted delete can be greater than or equal to 2!

Instance statement: delete from the table where the rowid in (select rowid from (
Select id, name, row_number () over (partition by id order by 1) from table b) where b>=2);
Explanation: on the basis of ORACLE's own inflated the ROWID, and according to it to delete, duplicate data before the query, also is the outcome of the sorted data ROWID is greater than or equal to 2, the data is what we want to delete the data;
Note: the table is a table
Row_number is a function analysis
  • Related