Delete the same data (only one record is left) across the oracle network and one record from oracle

Source: Internet
Author: User

Delete the same data (only one record is left) across the oracle network and one record from oracle

Delete from reg_user t1 WHERE user_name = '2013' and rowid> (SELECT min (rowid) FROM location t2 WHERE t1.user _ name = t2.user _ name );


How to use an SQL statement in Oracle to delete duplicate data (leave a piece of data)

Delete Emp p
Where rowid in
(
Select tmpid
(Select ROW_NUMBER () OVER (partition by id) id, rowid tmpid from emp)
Where id <> 1
)

Try it.

How does an oracle database retain only one duplicate data?

Delete from GXS_VIEW_PATIENT_INFO where rowid not in (select min (rowid) from GXS_VIEW_PATIENT_INFO group by a field)
A field is grouped by several groups.

For example, data
Id name
1
1
1

You can use either group by id or group by name.
However, if
Id name
1
1
1
2
However, as shown in the preceding figure, only one row can be retained at the end, so you have to find a group by field.

However, this should be used with caution. If there are too many data, it will be very slow. Back up the data before deletion.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.