When the Oracle database finds row n (n> = 2), how can we solve the problem that rownum cannot find ?, Oraclerownum
Oracle Database Problems
Rownum cannot be used to query row n (n> = 2 ).
The temporary solution is select * from (select rownum no, ename from emp) where no = 2;, but it is quite troublesome.
The rownum keyword in Oracle Database is special. It is a pseudo field in the query result that indicates the number of rows returned from the query, it can be used to LIMIT the number of rows in the query result (instead of the LIMIT keyword commonly used in Mysql ). However, it cannot be processed as a normal column of data. For example, if you want to find the first data in the table, you can use rownum = 1 to judge it, but you cannot find the second data, this is because when rownum is used to make an equal judgment, it is assumed that the natural numbers above 1 are false. Similarly, if you want to find all the data after the second record, that is, use rownum> 2 to judge the data, Oracle considers it unreasonable. Therefore, you can only search for the nth data. (It looks like it was set up to implement the LIMIT keyword, but I still don't understand why I don't directly set a LIMIT keyword. If you're lucky enough to have a master, please give me some advice, thank you !)
Supplement: when using the order by clause, you cannot directly use rownum to retrieve the first few pieces of data. You have to return the row number in the preceding method !!
These problems will be solved temporarily, and other problems will be updated later.