What is ROWID and ROWNUM in SQL with Examples?

In this article I would like  to explain ‘What is ROWID and ROWNUM in SQL?’. Pseudocolumns are actually associated with the table data but it has nothing to do with table data.ROWID & ROWNUM are Pseudocolumns which are not actual columns in the table but behave like actual columns. You can select the values from Pseudocolumns like ROWID & ROWNUM.ROWID & ROWNUM are very important Pseudocolumns in oracle which is used in data retrieval.

CLICK HERE TO GET 20 MOST IMPORTANT COMPLEX SQL QUERIES..

Pseudocolumns are nothing but logical columns which behaves like a physical columns in database.

                Rowid and Rownum in SQL

What is ROWID?

  1. ROWID is nothing but the physical memory location on which that data/row is stored.ROWID basically returns address of row.
  2. ROWID uniquely identifies row in database.
  3. ROWID is combination of data object number,data block in datafile,position of row and datafile in which row resides.
  4. ROWID is 16 digit hexadecimal number whose datatype is also ROWID Or UROWID
  5. The fastest way to access a single row is ROWID
  6. ROWID is unique identifier of the ROW.

CLICK HERE TO GET 20 IMPORTANT QUESTIONS ON PERFORMANCE TUNING

Example:- select rowid from dual;

AAAAECAABAAAAgiAAA

  • What is ROWNUM?

  1. ROWNUM is magical column in Oracle which assigns the sequence number to the rows retreives in the table.
  2. To limit the values in the table you can use rownum pseudocolumn
  3. ROWNUM is nothing but logical sequence number given to the rows fetched from the table.
  4. ROWNUM is logical number assigned temporarily to  the physical location of the row.
  5. You can limit the values in the table using rownum
  6. ROWNUM is also unique temparary sequence number assigned to that row.

Example:

Select Rownum from dual;

Answer- 1

So in above article we have dicussed the difference between ROWID & ROWNUM.Following is the difference between ROWID & ROWNUM in tabular format:

                       ROWID                            ROWNUM 
1.ROWID is nothing but Physical memory allocation

2.ROWID is permanant to that row which identifies the address of that row.

3.ROWID is 16 digit Hexadecimal number which is uniquely identifies the rows.

4.ROWID returns PHYSICAL ADDRESS of that row.

5. ROWID is automatically generated unique id of a row and it is generated at the time of insertion of row.

6. ROWID is the fastest means of accessing data.

1. ROWNUM is nothing but the sequence which is allocated to that data retreival bunch.

2. ROWNUM is tempararily allocated sequence to the rows.

3.ROWNUM is numeric sequence number allocated to that row temporarily.

4.ROWNUM returns the sequence number to that row.

5. ROWNUM is an dynamic value automatically
retrieved along with select statement output.

6.ROWNUM is not related to access of data.

Hope you like this article on What is ROWID and ROWNUM in SQL? . Kindly comment if any suggestions .

CLICK HERE TO GET 20 SQL INTERVIEW QUESTIONS FOR FRESHER.. 

HOME

Amit S

Oracle Consultant with vast experience in Oracle BI and PL/SQL Development. Amiet is the admin head of this website who contributes by preparing tutorials and articles related to database technologies. He is responsible to manage the content and front-end of the website.

Recent Posts

Application Support Engineer Day to day responsibilities

In my previous articles I have given the roles and responsibilities of L1,L2 and L3…

59 minutes ago

What is mean by SLA ( Service Level Agreement) with Examples?

In my previous articles i have given the hierarchy of production support in real company…

3 days ago

What is Production support Hierarchy in organization?

In this article i would like to provide information about production support organization structure or…

3 days ago

What are roles and responsibilities for L3 Support Engineer?

In my previous article I have given roles for L1 and L2 support engineer with…

3 days ago

What are roles and responsibilities of L2 Engineer?

I have started this new series of how to become application support engineer. This article…

3 days ago

What are Roles and Responsibilities of L1 Support Engineer with real industry examples?

In this series we are starting with Roles and responsibilities of L1 support engineer .…

3 days ago