ArcSDE10.2.1使用Oracle12c新特性分页
在Oracle 12c推出之后,其中一个新特性就是分页语句。 Easy Top-N and pagination queries ,更易用的Top-N和页码查 询提供了类似MySQL中limit的语法,Row Limiting Clause 注意:该功能是Oracle12c的新特性,并不是ArcGIS的新特性。 语法介绍 row_limiting_
在Oracle 12c推出之后,其中一个新特性就是分页语句。
Easy Top-N and pagination queries ,更易用的Top-N和页码查
询提供了类似MySQL中limit的语法,Row Limiting Clause
注意:该功能是Oracle12c的新特性,并不是ArcGIS的新特性。
语法介绍
<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
第一步:先把过滤第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中使用。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

磁力連結是一種用於下載資源的連結方式,相較於傳統的下載方式更為便利和有效率。使用磁力連結可以透過點對點的方式下載資源,而不需要依賴中介伺服器。本文將介紹磁力連結的使用方法及注意事項。一、什麼是磁力連結磁力連結是一種基於P2P(Peer-to-Peer)協定的下載方式。透過磁力鏈接,使用者可以直接連接到資源的發布者,從而完成資源的共享和下載。與傳統的下載方式相比,磁

mdf檔案和mds檔案怎麼用隨著電腦科技的不斷進步,我們可以透過多種方式來儲存和共享資料。在數位媒體領域,我們經常會遇到一些特殊的文件格式。在這篇文章中,我們將討論一種常見的文件格式—mdf和mds文件,並介紹它們的使用方法。首先,我們需要了解mdf檔案和mds檔案的含義。 mdf是CD/DVD鏡像檔的副檔名,而mds檔則是mdf檔的元資料檔。

foobar2000是一款能隨時收聽音樂資源的軟體,各種音樂無損音質帶給你,增強版本的音樂播放器,讓你得到更全更舒適的音樂體驗,它的設計理念是將電腦端的高級音頻播放器移植到手機上,提供更便捷高效的音樂播放體驗,介面設計簡潔明了易於使用它採用了極簡的設計風格,沒有過多的裝飾和繁瑣的操作能夠快速上手,同時還支持多種皮膚和主題,根據自己的喜好進行個性化設置,打造專屬的音樂播放器支援多種音訊格式的播放,它還支援音訊增益功能根據自己的聽力情況調整音量大小,避免過大的音量對聽力造成損害。接下來就讓小編為大

CrystalDiskMark是一款適用於硬碟的小型HDD基準測試工具,可快速測量順序和隨機讀取/寫入速度。接下來就讓小編為大家介紹一下CrystalDiskMark,以及crystaldiskmark如何使用吧~一、CrystalDiskMark介紹CrystalDiskMark是一款廣泛使用的磁碟效能測試工具,用於評估機械硬碟和固態硬碟(SSD)的讀取和寫入速度和隨機I/O性能。它是一款免費的Windows應用程序,並提供用戶友好的介面和各種測試模式來評估硬碟效能的不同方面,並被廣泛用於硬體評

輕鬆上手:如何使用pip鏡像來源隨著Python在全球的普及,pip成為了Python套件管理的標準工具。然而,許多開發者在使用pip安裝套件時面臨的常見問題是速度慢。這是因為預設情況下,pip從Python官方來源或其他外部來源下載包,而這些來源可能位於海外伺服器,導致下載速度緩慢。為了提高下載速度,我們可以使用pip鏡像來源。什麼是pip鏡像來源?簡單來說,就

MetaMask(中文也叫小狐狸錢包)是一款免費的、廣受好評的加密錢包軟體。目前,BTCC已支援綁定MetaMask錢包,綁定後可使用MetaMask錢包進行快速登錄,儲值、買幣等,且首次綁定還可獲得20USDT體驗金。在BTCCMetaMask錢包教學中,我們將詳細介紹如何註冊和使用MetaMask,以及如何在BTCC綁定並使用小狐狸錢包。 MetaMask錢包是什麼? MetaMask小狐狸錢包擁有超過3,000萬用戶,是當今最受歡迎的加密貨幣錢包之一。它可免費使用,可作為擴充功能安裝在網絡

網易郵箱,作為中國網友廣泛使用的一種電子郵箱,一直以來以其穩定、高效的服務贏得了用戶的信賴。而網易信箱大師,則是專為手機使用者打造的信箱軟體,它大大簡化了郵件的收發流程,讓我們的郵件處理變得更加便利。那麼網易信箱大師該如何使用,具體又有哪些功能呢,下文中本站小編將為大家帶來詳細的內容介紹,希望能幫助到大家!首先,您可以在手機應用程式商店搜尋並下載網易信箱大師應用程式。在應用寶或百度手機助手中搜尋“網易郵箱大師”,然後按照提示進行安裝即可。下載安裝完成後,我們打開網易郵箱帳號並進行登錄,登入介面如下圖所示

在如今雲端儲存已成為我們日常生活和工作中不可或缺的一部分。百度網盤作為國內領先的雲端儲存服務之一,憑藉其強大的儲存功能、高效的傳輸速度以及便捷的操作體驗,贏得了廣大用戶的青睞。而且無論你是想要備份重要文件、分享資料,還是在線上觀看影片、聽取音樂,百度網盤都能滿足你的需求。但很多用戶可能對百度網盤app的具體使用方法還不了解,那麼這篇教學就將為大家詳細介紹百度網盤app如何使用,還有疑惑的用戶們就快來跟著本文詳細了解一下吧!百度雲網盤怎麼用:一、安裝首先,下載並安裝百度雲軟體時,請選擇自訂安裝選
