I have a replication of around 200 records in a table, I want to remove all of then except one, how can I do this ??
Asked
Active
Viewed 3,945 times
1
-
1Have a look on this http://stackoverflow.com/questions/59232/how-do-i-find-duplicate-values-in-a-table-in-oracle. If this is your case kindly close this thread. – Viki888 Nov 24 '16 at 07:12
-
@viki888, I am asking about deletion not to find duplicates :) – KeenLearner Nov 24 '16 at 07:13
-
DELETE FROM Table WHERE (...your select query with limit 199...) – dgk Nov 24 '16 at 07:14
-
@rana,Did you try anything – Mansoor Nov 24 '16 at 07:15
-
table structure please – Samuel Robert Nov 24 '16 at 07:15
-
@mww, works thanku, but can you elaborate please – KeenLearner Nov 24 '16 at 07:18
2 Answers
0
Source http://www.devx.com
It's easy to introduce duplicate rows of data into Oracle tables by running a data load twice without the primary key or unique indexes created or enabled.Here column1, column2, column3 constitute the identifying key for each record.
DELETE FROM our_table
WHERE rowid not in
(SELECT MIN(rowid)
FROM our_table
GROUP BY column1, column2, column3) ;

M. Wiśnicki
- 6,094
- 3
- 23
- 28
-2
use the following query. This will be applicable if there is an Id available for the table.
delete from tableA where id in(select top 199 id from tableA)

Ajith Menon
- 42
- 1