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 )
return code before grep
-
my 2009 solution return code before grep ( ( ( mycmd echo $? >&3 ) |grep
mytext >&4 ) 3>&1 |(read x;exit $x) )4>&1 my 2025 solution mycmd > >(grep
mytext)
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