Oracle Delete duplicate records __oracle

Source: Internet
Author: User

The best way for Oracle to delete duplicate records:
DELETE from EMP E WHERE e.rowid > (SELECT MIN (Y.ROWID)
From EMP y
WHERE y.empno = e.empno)

1, subquery find the lowest ROWID (certainly only one), other than this record ROWID, delete all.

2, Oracle use ROWID to delete duplicate records fastest, because the ROWID corresponds to the location of this record on disk

Interview: Performance optimization

Rule: Avoid using ' * ' in SELECT clause
Rule: Use EXISTS statement instead of in statement;
Use NOT exists instead of in
Rules: Using truncate instead of the DELETE from table statement
Rule: Reduce the number of accesses to the database
Rule: Reduce the number of accesses to the database
Rules: Using table aliases (alias)
Rule: Use commit as soon as possible
Rules: Design of database redundant fields
Other: Oracle performance-related features (three buffers)

Interviewer: Why do companies often use Oracle? Why is Oracle so bull?
Answer: Start with three buffers
One, log buffer
• When adding a record, the database also logs a log in the background
· Oracle can write the log in memory first, then write to disk once the buffer is full
Second, block buffer
• If a table, such as a departmental table, is infrequently updated but often used, you can save the table in memory to avoid frequent disk access.
• The speed of access to memory is greater than the speed at which the disk is accessed.
Three, SQL buffer
• Database Execution steps: syntax analysis, semantic analysis, compilation, optimization ...
• So the time that SQL consumes is very long before it is executed.
· The Oracle database saves SQL in a SQL buffer, and if you execute the same SQL, you will only compile the analysis once, no matter how many times. Thus reducing analysis and optimization

Between

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.