The use and difference of Oracle's pseudo-column rownum and ROWID

Source: Internet
Author: User

The use of rownum

Select Rownum,empno,ename,job from emp where rownum<6

You can get value data that is less than 6

Select Rownum,empno,ename,job from emp where rownum>6 and rownum<10

No data reason: Oracle first produces a number of 1 data, that is, the condition is not satisfied, then the same will continue to produce the second data is also numbered 1, so the final data is not

Solution: You can turn the Select Rownum,empno,ename,job from emp into a subquery

The use of ROWID can be repeated data

Unlike the rownum pseudo-column, he is a physical presence, ROWID is a data type, based on 64-bit encoded 18 characters to uniquely flag a record of the physical location of a id,rowid can be queried in the table, but its value is not stored in the table, so do not support additions and deletions to change the operation

For example, there are two identical data

Delete from TableName where rowID not in (select min (rowid) from TableName Group By column name

The use and difference of Oracle's pseudo-column rownum and ROWID

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.