Oracle analysis function for deleting duplicate data

Source: Internet
Author: User

There are 16.77 million data records in a table, and 5.71 million data records are different. When not all fields have the same content, for example, 100 people with the same name and surname have different salaries, and other fields have the same content.

You cannot use the rowid method.

The statement is as follows:
Query data:
Select * from table 1 Where rowid! = (Select max (rowid)
From table1 B where a. name1 = B. name1 and a. name2 = B. name2 ......)
Delete data:
Delete from table 1 Where rowid! = (Select max (rowid)
From table1 B where a. name1 = B. name1 and a. name2 = B. name2 ......)

Use

Delete from emp2
2 WHERE ROWID IN
3 (SELECT ROWID
4 FROM (Select rowid,
5 ROW_NUMBER () OVER (partition by empno order by empno) rn
6 FROM emp2
)
7 WHERE rn> 1 );

Delete a row based on the employee ID and leave only one row

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.