搜索
首页数据库mysql教程ArcSDE10.2.1使用Oracle12c新特性分页

在Oracle 12c推出之后,其中一个新特性就是分页语句。 Easy Top-N and pagination queries ,更易用的Top-N和页码查 询提供了类似MySQL中limit的语法,Row Limiting Clause 注意:该功能是Oracle12c的新特性,并不是ArcGIS的新特性。 语法介绍 row_limiting_


ArcSDE10.2.1使用Oracle12c新特性分页

在Oracle 12c推出之后,其中一个新特性就是分页语句。

Easy Top-N and pagination queries ,更易用的Top-N和页码查

询提供了类似MySQL中limit的语法,Row Limiting Clause

 注意:该功能是Oracle12c的新特性,并不是ArcGIS的新特性。

ArcSDE10.2.1使用Oracle12c新特性分页

语法介绍

<span>row_limiting_clause</span>

The <span>row_limiting_clause</span> allows you to limit the rows returned by the query. You can specify an offset, and number of rows or percentage of rows to return. You can use this clause to implement top-N reporting. For consistent results, specify the <span>order_by_clause</span> to ensure a deterministic sort order.


OFFSET

Use this clause to specify the number of rows to skip before row limiting begins. <span>offset</span> must be a number. If you specify a negative number, then <span>offset</span> is treated as 0. If you specify NULL, or a number greater than or equal to the number of rows returned by the query, then 0 rows are returned. If <span>offset</span> includes a fraction, then the fractional portion is truncated. If you do not specify this clause, then <span>offset</span>is 0 and row limiting begins with the first row.


ROW | ROWS These keywords can be used interchangeably and are provided for semantic clarity.


FETCH

Use this clause to specify the number of rows or percentage of rows to return. If you do not specify this clause, then all rows are returned, beginning at row <span>offset</span> + 1.

FIRST | NEXT These keywords can be used interchangeably and are provided for semantic clarity.


<span>rowcount</span> | <span>percent</span> PERCENT Use <span>rowcount</span> to specify the number of rows to return. <span>rowcount</span> must be a number. If you specify a negative number, then <span>rowcount</span> is treated as 0. If <span>rowcount</span> is greater than the number of rows available beginning at row <span>offset</span> + 1, then all available rows are returned. If <span>rowcount</span> includes a fraction, then the fractional portion is truncated. If <span>rowcount</span> is NULL, then 0 rows are returned.


Use <span>percent</span> PERCENT to specify the percentage of the total number of selected rows to return. <span>percent</span> must be a number. If you specify a negative number, then <span>percent</span> is treated as 0. If <span>percent</span> is NULL, then 0 rows are returned.

If you do not specify <span>rowcount</span> or <span>percent</span> PERCENT, then 1 row is returned.


ROW | ROWS These keywords can be used interchangeably and are provided for semantic clarity.


ONLY | WITH TIES Specify ONLY to return exactly the specified number of rows or percentage of rows.

Specify WITH TIES to return additional rows with the same sort key as the last row fetched. If you specify WITH TIES, then you must specify the<span>order_by_clause</span>. If you do not specify the <span>order_by_clause</span>, then no additional rows will be returned.


当然,大家最喜欢看的就是实际的例子,总结上面就是,在Oracle12c

环境下,提供了更加方便的分页语句,而不再使用Rownum对象了。


测试环境:

ArcSDE10.2.1、Oracle12.1.0.1

sde@PDBORCL> select count(*) from point;

  COUNT(*)
----------
    231774

sde@PDBORCL> select count(*) from poly;

  COUNT(*)
----------
        13

----------------------------------------------------------------------------------


Blog:               http://blog.csdn.net/linghe301

----------------------------------------------------------------------------------


1:获得前N条记录的语句

语法: fetch first N rows only;

sde@PDBORCL> set autotrace on
sde@PDBORCL> select a.objectid,a.poi_name from poly b,point a where sde.st_within(a.shape,b.shape)=1 order by a.objectid fetch first 10 rows only;

  OBJECTID POI_NAME
---------- ----------------------------------------------------------------------
      1326 96699994
      1790 96700095
      6511 96700093
      8761 96698253
      9650 96698338
     10186 96699086
     10597 96700092
     12400 96698659
     12443 96700465
     14594 96699995

已选择10行。


执行计划
----------------------------------------------------------
Plan hash value: 3842462730

-------------------------------------------------------------------------------------------
| Id  | Operation                        | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |        |     1 |    76 |    55   (0)| 00:00:01 |
|*  1 |  VIEW                            |        |     1 |    76 |    55   (0)| 00:00:01 |
|*  2 |   WINDOW SORT PUSHED RANK        |        |     1 |   417 |    55   (0)| 00:00:01 |
|   3 |    NESTED LOOPS                  |        |     1 |   417 |    55   (0)| 00:00:01 |
|   4 |     TABLE ACCESS FULL            | POLY   |    13 |  2964 |     3   (0)| 00:00:01 |
|   5 |     TABLE ACCESS BY INDEX ROWID  | POINT  |     1 |   189 |    55   (0)| 00:00:01 |
|*  6 |      DOMAIN INDEX (Sel: .0000043)| A6_IX1 |       |       |     4   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("from$_subquery$_003"."rowlimit_$$_rownumber"通过SQL的执行计划可以看出,系统还是通过Rownum来进行分页<p><span>的,是否我可以理解Oracle封装了一下,做了个二次开发呢?</span></p><p><span><br></span></p><p></p><p><strong><span>----------------------------------------------------------------------------------</span></strong></p><p></p><p><span><span><br></span></span></p><p><span><span>Blog:               http://blog.csdn.net/linghe301</span></span></p><p><strong><span>----------------------------------------------------------------------------------</span></strong></p><br><p><span>2:获得第N条开始后的M条的语句</span></p><p><span>语法:offset N rows fetch next M rows only;</span></p><pre class="brush:php;toolbar:false">sde@PDBORCL> select a.objectid from poly b,point a where sde.st_within(a.shape,b.shape)=1  order by a.objectid offset 11 rows fetch next 10 rows only;

  OBJECTID
----------
     17833
     18358
     18710
     19544
     19719
     20030
     23028
     24001
     25139
     25257

已选择10行。


执行计划
----------------------------------------------------------
Plan hash value: 3842462730

-------------------------------------------------------------------------------------------
| Id  | Operation                        | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |        |     1 |    39 |    55   (0)| 00:00:01 |
|*  1 |  VIEW                            |        |     1 |    39 |    55   (0)| 00:00:01 |
|*  2 |   WINDOW SORT PUSHED RANK        |        |     1 |   417 |    55   (0)| 00:00:01 |
|   3 |    NESTED LOOPS                  |        |     1 |   417 |    55   (0)| 00:00:01 |
|   4 |     TABLE ACCESS FULL            | POLY   |    13 |  2964 |     3   (0)| 00:00:01 |
|   5 |     TABLE ACCESS BY INDEX ROWID  | POINT  |     1 |   189 |    55   (0)| 00:00:01 |
|*  6 |      DOMAIN INDEX (Sel: .0000043)| A6_IX1 |       |       |     4   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("from$_subquery$_003"."rowlimit_$$_rownumber"=0)
              THEN 11 ELSE 0 END +10 AND "from$_subquery$_003"."rowlimit_$$_rownumber">11)
   2 - filter(ROW_NUMBER() OVER ( ORDER BY "A"."OBJECTID")=0)
              THEN 11 ELSE 0 END +10)
   6 - access("SDE"."ST_WITHIN"("A"."SHAPE","B"."SHAPE")=1)


统计信息
----------------------------------------------------------
        647  recursive calls
          0  db block gets
       2481  consistent gets
          0  physical reads
          0  redo size
        457  bytes sent via SQL*Net to client
        359  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
         10  rows processed
关于Next的用法分为两步

第一步:先把过滤第1到第N-1的数据

第二步:然后再获得第N到M的数据

----------------------------------------------------------------------------------


Blog:               http://blog.csdn.net/linghe301

----------------------------------------------------------------------------------



3:获得前百分比N的语句

语法: fetch first N percent rows only;

sde@PDBORCL> select a.objectid from poly b,point a where sde.st_within(a.shape,b.shape)=1 order by a.objectid fetch first 10 percent rows only;

  OBJECTID
----------
      1326
      1790
      6511
      8761
      9650
     10186
     10597
     12400
     12443
     14594
     15163
     17833
     18358
     18710
     19544
     19719

已选择16行。


执行计划
----------------------------------------------------------
Plan hash value: 2419008321

-------------------------------------------------------------------------------------------
| Id  | Operation                        | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |        |     1 |    52 |    55   (0)| 00:00:01 |
|*  1 |  VIEW                            |        |     1 |    52 |    55   (0)| 00:00:01 |
|   2 |   WINDOW SORT                    |        |     1 |   417 |    55   (0)| 00:00:01 |
|   3 |    NESTED LOOPS                  |        |     1 |   417 |    55   (0)| 00:00:01 |
|   4 |     TABLE ACCESS FULL            | POLY   |    13 |  2964 |     3   (0)| 00:00:01 |
|   5 |     TABLE ACCESS BY INDEX ROWID  | POINT  |     1 |   189 |    55   (0)| 00:00:01 |
|*  6 |      DOMAIN INDEX (Sel: .0000043)| A6_IX1 |       |       |     4   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("from$_subquery$_003"."rowlimit_$$_rownumber"<br><p><span>从这些语句可以看到,原来使用比较麻烦的分页SQL写法,现在变得</span></p><p><span>比较简单和方便了。</span></p><p><span><br></span></p><p><span>目前来说,我在ArcGIS10.2.1 for Server进行Rest测试,还不支持该</span></p><p><span>方法,希望Esri能够尽快改进吧。</span></p><p></p><p><strong><span>----------------------------------------------------------------------------------</span></strong></p><p></p><p><span><span><br></span></span></p><p><span><span>Blog:               http://blog.csdn.net/linghe301</span></span></p><p><strong><span>----------------------------------------------------------------------------------</span></strong></p><br><p><span>另外需要说明一个问题。</span></p><p><span>很多情况下都会出现这种现象,比如在一个班级里面的数据成绩,从</span></p><p><span>最高排序有100、99、97、97、94等</span></p><p><span>那么,第一名就是100,第二名就是99,第三名应该是并列两个97,</span></p><p><span>那么在上面的语句中我们看到有一个ONLY关键字。</span></p><p><span><br></span></p><p><span>如果使用ONLY关键字,那么如果用户需要获得排序后的前三名,那么</span></p><p><span>只有100、99、97,显然这个不符合实际情况,所以用户应该使用</span></p><p><span>WITH TIES关键字,这样虽然获得前三名,得到的结果是真实的四个</span></p><p><span>数据。</span></p><pre class="brush:php;toolbar:false">sde@PDBORCL> select objectid,num from aaa;

  OBJECTID        NUM
---------- ----------
         1          1
         2          2
         3          3
         4          3
         5          3
         6          4
         7          4
         8          5

已选择8行。

sde@PDBORCL>
sde@PDBORCL> select  objectid,num from aaa order by num  fetch first 3  rows only;

  OBJECTID        NUM
---------- ----------
         1          1
         2          2
         3          3

sde@PDBORCL> select  objectid,num from aaa order by num  fetch first 3  rows with ties;

  OBJECTID        NUM
---------- ----------
         1          1
         2          2
         3          3
         4          3
         5          3

----------------------------------------------------------------------------------


Blog:               http://blog.csdn.net/linghe301

----------------------------------------------------------------------------------


PS:该功能目前可以在ArcGIS Desktop中使用,但是不能再


REST中使用。



ArcSDE10.2.1使用Oracle12c新特性分页

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
在MySQL中使用视图的局限性是什么?在MySQL中使用视图的局限性是什么?May 14, 2025 am 12:10 AM

mysqlviewshavelimitations:1)他们不使用Supportallsqloperations,限制DatamanipulationThroughViewSwithJoinSorsubqueries.2)他们canimpactperformance,尤其是withcomplexcomplexclexeriesorlargedatasets.3)

确保您的MySQL数据库:添加用户并授予特权确保您的MySQL数据库:添加用户并授予特权May 14, 2025 am 12:09 AM

porthusermanagementInmysqliscialforenhancingsEcurityAndsingsmenting效率databaseoperation.1)usecReateusertoAddusers,指定connectionsourcewith@'localhost'or@'%'。

哪些因素会影响我可以在MySQL中使用的触发器数量?哪些因素会影响我可以在MySQL中使用的触发器数量?May 14, 2025 am 12:08 AM

mysqldoes notimposeahardlimitontriggers,butacticalfactorsdeterminetheireffactective:1)serverConfiguration impactactStriggerGermanagement; 2)复杂的TriggerSincreaseSySystemsystem load; 3)largertablesslowtriggerperfermance; 4)highConconcConcrencerCancancancancanceTigrignecentign; 5); 5)

mysql:存储斑点安全吗?mysql:存储斑点安全吗?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

mySQL:通过PHP Web界面添加用户mySQL:通过PHP Web界面添加用户May 14, 2025 am 12:04 AM

通过PHP网页界面添加MySQL用户可以使用MySQLi扩展。步骤如下:1.连接MySQL数据库,使用MySQLi扩展。2.创建用户,使用CREATEUSER语句,并使用PASSWORD()函数加密密码。3.防止SQL注入,使用mysqli_real_escape_string()函数处理用户输入。4.为新用户分配权限,使用GRANT语句。

mysql:blob和其他无-SQL存储,有什么区别?mysql:blob和其他无-SQL存储,有什么区别?May 13, 2025 am 12:14 AM

mysql'sblobissuitableForStoringBinaryDataWithInareLationalDatabase,而alenosqloptionslikemongodb,redis和calablesolutionsoluntionsoluntionsoluntionsolundortionsolunsolunsstructureddata.blobobobsimplobissimplobisslowderperformandperformanceperformancewithlararengelitiate;

mySQL添加用户:语法,选项和安全性最佳实践mySQL添加用户:语法,选项和安全性最佳实践May 13, 2025 am 12:12 AM

toaddauserinmysql,使用:createUser'username'@'host'Indessify'password'; there'showtodoitsecurely:1)choosethehostcarecarefullytocon trolaccess.2)setResourcelimitswithoptionslikemax_queries_per_hour.3)usestrong,iniquepasswords.4)Enforcessl/tlsconnectionswith

MySQL:如何避免字符串数据类型常见错误?MySQL:如何避免字符串数据类型常见错误?May 13, 2025 am 12:09 AM

toAvoidCommonMistakeswithStringDatatatPesInMysQl,CloseStringTypenuances,chosethirtightType,andManageEngencodingAndCollat​​ionsEttingsefectery.1)usecharforfixed lengengters lengengtings,varchar forbariaible lengength,varchariable length,andtext/blobforlabforlargerdata.2 seterters seterters seterters seterters

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SecLists

SecLists

SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器