The difference between rownum and ROWID in Oracle

Source: Internet
Author: User

The difference between rownum and rowID is summed up:

RowNum and rowID are pseudo-columns, but the two are fundamentally different.

RowNum is to assign a logical number to each row based on the results of the SQL query, so your SQL will cause the final rownum to be different.

However, ROWID is a physical structure that has a unique physical record when each record is insert into the database.

    • RowNum Paging:

using rownum for Oracle paging

    • rowID, the primary key is still unique , only to remove the name and age of repeat students:
Select A.rowid,a.* from Student a        where A.rowid not in              (SELECT MAX (b.rowid) from student b where a.sname = B.sname and a.sage = B.sage);

The above SQL statement is difficult to understand because the source and target are cross-queried.

Chinese interpretation (from the inner Select to start understanding):

1. From the Studneta table, find and STUDENTB the same name and the same age students in the table.

2. Find out the biggest rowid of the students with the same name.

3. From the Studenta table, look for those students who are not in the maximum rowid range.

The really used de-redo statements are:

DELETE from Student a        where A.rowid not in              (SELECT MAX (b.rowid) from student b WHERE a.sname = B.sname and A.sage = B.sage);

More detailed references for ROWID:

Efficient way to remove duplicate data from an Oracle database

  The difference between rownum and ROWID in Oracle

The difference between rownum and ROWID in Oracle

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.