Difference between rowid and rownum

          

Difference between rowid and rownum

<<Previous  Next>>

Oracle - Difference between rowid and rownum - Feb 18, 2010 at 11:00 PM by Rajmeet Ghai

Explain the difference between rowid and rownum.  

ROWID is a unique pseudo number assigned to a row. Rownum returns the number of rows for a resultant query. BOTH are pseudo columns not occupying any physical space in the database.

Example of Rownum:
Sort salary and return first 5 rows.
select * from
( select *
       from emp 
       order by sal desc )
where ROWNUM <= 5;

Example of Rowid:
Below query selects address of all rows that contain data for students in department 20
SELECT ROWID, last_name
       FROM student
       WHERE department_id = 20;

Oracle - Difference between rowid and rownum - April 10, 2009 at 11:00 AM

Explain the difference between rowid and rownum.  

RowId represents a row in a table internally. It can be used for fast access to the row. Rownum is a function of the result set.
select * from Student where rownum = 2 will get the first 2 rows of your result set.

Also read
Oracle clusters

A cluster contains data from one or more tables. All these tables have one or more columns in common. All the rows from all the tables that share the same cluster key...............  

Oracle constraints

Explain the constraints that can be applied to Oracle tables, Explain various types of constraints in Oracle, What is an integrity constraint?.................  

What is CYCLE/NO CYCLE in a oracle sequence?

When a sequence is created using CYCLE option, values for the column are regenerated from MINVALUE once MAXVALUE is reached..........  

Oracle database tuning

Automatic Performance Diagnostic and Tuning Features, Automatic Shared Memory Management - Automatic Shared Memory Management puts Oracle in control of allocating memory within the SGA...........

<<Previous  Next>>



Write your comment - Share Knowledge and Experience

Discussion Board
ROWNUM

Shuvam is correct

King 05-6-2013 03:39 PM

ROWNUM

Guys,

You have wrong concept of ROWNUM.

King 05-6-2013 03:38 PM

Rownum reference

As shown above to select first two rowsthe code written is...
select * from where rownum=2.
I do have a doubt if we really we can write a "rownum =2".Equality operator can only be assigned if we write rownum=1..otherwise except 1 it does not go with any of the number assigned with rownum...
Rather to select first two rows of a table the query can be written like this.
1) SELECT * FROM WHERE ROWNUM<=2.
2) SELECT * FROM WHERE ROWNUM<3
Thanks and regards,
Shuvam

shuvam dutta 10-15-2012 01:44 AM

 

 

 

Interview questions
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring