Method 1:
DELETE from table_name A
where rowid > (select min(rowid) from table_name B where A.key_values = B.key_values);
Method 2:
create table table_name2 as select distinct * from table_name1;
drop table table_name1;
rename table table_name2 as table_name1;
In this method, all the indexes,constraints,triggers etc have to be re-created.
Method 3:
DELETE from table_name t1
where exists (select 'x' from table_name t2 where t1.key_value=t2.key_value
and t1.rowid > t2.rowid)
Method 4:
DELETE from table_name where rowid not in (select min(rowid) from my_table group by key_value )
TIME_BUCKET group by time period
-
We all know how to sum up by year select
to_char(trunc(hiredate,'Y'),'YYYY') year, count(*) from scott.emp group by
trunc(hiredate,'Y') order by trunc(hire...
1 week ago
1 comment:
There is a flaw in method 4, This method would fail if there are more than one duplicate rows.
Post a Comment