$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 10月 9 14:45:19 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
SQL> select * from exitgogo8;
TEST
--------------------------------------------------------------------------------
1
2
3
TEST
--------------------------------------------------------------------------------
4
SQL> select * from exitgogo8 where rownum=1;
TEST
--------------------------------------------------------------------------------
1
SQL> select * from exitgogo8 where rownum=2;
未选定行
SQL> select * from exitgogo8 where rownum=3;
未选定行
SQL> select * from exitgogo8 where rownum>1;
未选定行
SQL> select * from exitgogo8 where rownum>2;
未选定行
SQL> select * from exitgogo8 where rownum>-1;
TEST
--------------------------------------------------------------------------------
1
2
3
TEST
--------------------------------------------------------------------------------
4
SQL> select * from exitgogo8 where rownum>0;
IXDBA.NET社区论坛
TEST
--------------------------------------------------------------------------------
1
2
3
TEST
--------------------------------------------------------------------------------
4
SQL> select * from exitgogo8 where rownum<1;
未选定行
SQL> select * from exitgogo8 where rownum<2;
TEST
--------------------------------------------------------------------------------
1
SQL> select * from exitgogo8 where rownum<3;
TEST
--------------------------------------------------------------------------------
1
2
SQL> select * from exitgogo8 where rownum<4;
TEST
--------------------------------------------------------------------------------
1
2
3
TEST
--------------------------------------------------------------------------------
SQL> select * from exitgogo8 where rownum<=4;
TEST
--------------------------------------------------------------------------------
1
2
3
TEST
--------------------------------------------------------------------------------
4
SQL>
总结如下:
由此可见,只有当条件为rownum=1的时候才会有记录选出,其他数值均无选定行。
Oracle会给所有满足查询条件的记录指定一个顺序的数字(rownum)
对于满足的第一条记录