Multiple choice technology databases

If emp table having 10 records what is the output of : select * from emp where rownum=8;

  1. It throws error

  2. it will give 8th row

  3. no rows will get displayed

  4. None

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In Oracle, ROWNUM is assigned to rows as they are retrieved, starting from 1. A query like 'WHERE ROWNUM=8' tries to find the 8th row, but ROWNUM is assigned incrementally. By the time any row could potentially be the 8th row, ROWNUM values 1-7 haven't been satisfied, so the condition never matches. The query returns no rows.