oracle 12c 原生实现结果集的随意获取(类似 mysql 的 limit、offset )

os: centos 7.4
db: oracle 12c

版本
# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 

# su - oracle
$ sqlplus / as sysdba

SQL set lines 500;
set pages 500;

SQL select * from v$version;

BANNER										     CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production		  0
PL/SQL Release 12.1.0.2.0 - Production							  0
CORE	12.1.0.2.0	Production								  0
TNS for Linux: Version 12.1.0.2.0 - Production						  0
NLSRTL Version 12.1.0.2.0 - Production							  0

fetch first
SQL column OBJECT_ID format 9999999;
column OWNER format a20;
column OBJECT_NAME format a30;

SQL select OBJECT_ID,OWNER,OBJECT_NAME from dba_objects order by OBJECT_ID 
fetch first 5 rows only;

OBJECT_ID OWNER 	       OBJECT_NAME
--------- -------------------- ------------------------------
	2 SYS		       C_OBJ#
	3 SYS		       I_OBJ#
	4 SYS		       TAB$
	5 SYS		       CLU$
	6 SYS		       C_TS#

offset、fetch next
SQL select OBJECT_ID,OWNER,OBJECT_NAME from dba_objects order by OBJECT_ID 
offset 2 rows 
fetch next 5 rows only;

OBJECT_ID OWNER 	       OBJECT_NAME
--------- -------------------- ------------------------------
	4 SYS		       TAB$
	5 SYS		       CLU$
	6 SYS		       C_TS#
	7 SYS		       I_TS#
	8 SYS		       C_FILE#_BLOCK#
	
最新回复(0)
/jishu777Cc15SZy6ACeFA7U2_2FQoYqxjd7r0S6SxpTdQ_3D_3D4834044
8 简首页