Introduction to rowid and rownum in Oracle

Source: Internet
Author: User

Question: Does Oracle differentiate rowid from rownum? If they have differences, what are their differences?

A: Just as your address uniquely identifies your location, an oracle rowid uniquely identifies the physical address of a piece of data.
Rowid provides all the information you need to find this row of data, hard disk number, cylinder, block and the offset address on the block.
Rownum is a pseudo code, a placeholder that you can reference in SQL * Plus. Rownum can be used to write professional SQL statements and adjust SQL statements.

Note the following when using rownum in SQL statements:
Correct: Where rownum <N;
Where rownum = 1;
Error: Where rownum> N;
Where rownum = some_num> 1
This is correct if you have:
Select * from (
Select rownum RN, T. * from t
)
Where Rn = 3;

For example, to display the first five pieces of data, you can use rownum as a filter:
SQL> select rownum, EMP. empno, EMP. ename, EMP. Job from EMP
2 Where rownum <= 5;

Rownum empno ename job
----------------------------------
1 7369 Smith clerk
2 7499 Allen salesman
3 7521 ward salesman
4 7566 Jones Manager
5 7654 Martin salesman

In short, the difference between rowid and rownum is that rownum is temporary while rowid is permanent.

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.