How to delete duplicate records in oracle

Source: Internet
Author: User

Methods for deleting duplicate records (experiment description ):

1. The table stu contains 16 data records, including select rowid, xh, xm, sex, birthday, classid, and degree from stu.
Order by xh; 2. copy the data in the stu table into two copies for the experiment. After the experiment is copied, a total of 32 data entries are repeated, such. Insert into stu select * from stu;

3. for the same data, rowid is unique. Therefore, you can use rowid to delete duplicate data and group the same data. Only the smallest ROWID is retained. The SQL statement is as follows: delete from stu where ROWID not in (-- each of the same minimum ROWID

Select min (ROWID) from stu group by xh); after the SQL statement is executed, the query result is 16 original data records, for example:

4. If there are more than two duplicate data entries, the same applies.

Author: "To_Be_Monster_Of_IT"

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.