How to delete the same record in the oracle library
How to delete the same record in the oracle library, but keep a record in a duplicate record:
Solution: you can use the rowid pseudo-column in oracle to do this:
1. Create a temporary table and insert the duplicate data from the query (can I create a view?) :
Create table temp_woods as
(select item_id,count (*) as rowcount from wooods group by item_id having count (*) > 1)
two。 Query the same record:
Select A. from woods b where b.item_id in. Rowid from woods a where a.rowid (select max (b.rowid) from woods b where b.item_id in (select item_id from temp_woods) where b.item_id = a.item_id)
3. Delete duplicate records and keep the record with the largest rowid column:
Delete from woods a where a.rowid (select max (b.rowid) from woods b where b.item_id in (select item_id from temp_woods) where b.item_id = a.item_id)
4. Delete temporary tables:
Drop table temp_woods cascade constraints