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.