select * from emp where rownum<=1 gives one record....but
select * from emp where rownum=2 or any number doesn't give any records..what's the reason
--------------------------------------------------------------------------------------------------------
A ROWNUM is not data in the database or table. It has no relationship to anything in the database, including tables, tablespaces, data files, or to the order in which a row is inserted into a table.
ROWNUM returns a number indicating the order in which Oracle select the row from the table. The first row has rownum 1, the second 2 etc.......
Here If row is fetched then ROWNUM will generate at runtime,As ROWNUM is a Pseudo Column, it generates values at runtime of the Query.
SO HERE --> the first row fetched has rownum 1, and makes the where condition false. The next row, the second, is now the first row and has rownum 1, and makes the where condition false..
select * from emp where rownum=2 or any number doesn't give any records..what's the reason
--------------------------------------------------------------------------------------------------------
A ROWNUM is not data in the database or table. It has no relationship to anything in the database, including tables, tablespaces, data files, or to the order in which a row is inserted into a table.
ROWNUM returns a number indicating the order in which Oracle select the row from the table. The first row has rownum 1, the second 2 etc.......
Here If row is fetched then ROWNUM will generate at runtime,As ROWNUM is a Pseudo Column, it generates values at runtime of the Query.
SO HERE --> the first row fetched has rownum 1, and makes the where condition false. The next row, the second, is now the first row and has rownum 1, and makes the where condition false..
No comments:
Post a Comment