[Database] Oracle deduplicates data
As follows, the data table structure
id | name | pass |
---|---|---|
1 | aaa | 111 |
2 | bbb | 222 |
3 | ccc | 333 |
Through SQL, the following effects are achieved:
id | name | pass |
---|---|---|
1 | aaa | 111 |
2 | bbb | 222 |
3 | ccc | 333 |
1 | aaa | 111 |
2 | bbb | 222 |
3 | ccc | 333 |
Implement SQL:
insert into test_001 (id,name,pass) select id,name,pass from test_001 ;
commit;
deduplicate data
delete from test_001 where name in (select name from test_001 group by name having count(name)>1)
and rowid not in (select min(rowid) from test_001 group by name having count(name)>1) ;
commit;