在Oracle中,可以使用ROWNUM來(lái)篩選數(shù)據(jù),以下是一些示例:
SELECT * FROM table_name WHERE ROWNUM <= 10;
SELECT * FROM
(SELECT t.*, ROWNUM rnum FROM
(SELECT * FROM table_name ORDER BY column_name) t
WHERE ROWNUM <= 20)
WHERE rnum >= 11;
SELECT * FROM table_name WHERE ROWNUM <= 10 ORDER BY dbms_random.value;
SELECT * FROM table_name WHERE ROWNUM = n;
注意:ROWNUM 是在查詢結(jié)果集返回給客戶端之前生成的一個(gè)偽列,因此不能在 WHERE 子句中對(duì) ROWNUM 進(jìn)行篩選,只能在 SELECT 子句或 ORDER BY 子句中使用。