


Detailed explanation of the basic principles of Oracle paging query
This article mainly introduces the principle of Oracle paging query in detail, and analyzes the implementation method from the example test data. This article analyzes the basic knowledge of Oracle paging query in detail from the data query principle and paging implementation method. The following is this article Content:
Reason 1
Oracle generates rowmun and rowid fields for each table by default. We call these fields pseudo columns
1 Create a test table
CREATE TABLE TEST( ID NUMBER, NAME VARCHAR2(20) )
2 Insert test data
INSERT INTO TEST VALUES (1,'张三'); INSERT INTO TEST VALUES (2,'李四'); INSERT INTO TEST VALUES (3,'王五'); INSERT INTO TEST VALUES (4,'赵六'); INSERT INTO TEST VALUES (5,'郑七'); INSERT INTO TEST VALUES (6,'胡八'); INSERT INTO TEST VALUES (7,'刘九');
3 Check the table fields and confirm that the built-in fields
select rowid,rownum,id,name from TEST;
4 rowid are generally not used. , used internally by Oracle to store the physical location of rows. Related to paging is rownum, which is the row number
二
1 Query rows less than 5 and get four results
select rowid,rownum,id,name from test where rownum <p><br></p><p style="text-align: center"><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/054/025/435b600fe4db49f503f78ce320557549-1.png?x-oss-process=image/resize,p_40" class="lazy" alt=""></p><p>2 Query rows greater than 2 and less than 5</p><p class="cnblogs_code"><br></p> <pre class="brush:php;toolbar:false">select rownum,id,name from test where rownum>2 and rownum <p><br></p><p>I found nothing, what’s the reason?,</p><p>rownum has the following characteristics:</p><p>1 ROWNUM is only applicable to less than or less than Equal, if equal judgment is made, it can only be equal to 1; </p><p>2 ROWNUM is the number of rows allocated sequentially by the Oracle system. The first row returned is allocated 1, the second row is 2, and so on. ;</p><p>3 ROWNUM always starts from 1</p><p>4 The first data row number is 1 and does not meet the condition of >2, then the first row is removed, and the previous second row It becomes the new first row, and so on, until the last row, the condition is never satisfied, so not even a single piece of data can be found. </p><p style="max-width:90%"><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/054/025/ac875cc9f4d678726fb8d77d884e69b4-2.png?x-oss-process=image/resize,p_40" class="lazy" alt=""></p><p>3 Correct way to write it: Because > cannot be used, use the inner query to query the row number as a result set, and use the inner result set for comparison in the outer layer. </p><p class="cnblogs_code"><br></p><pre class="brush:php;toolbar:false">select rownum,id,name from ( select rownum rn, u.* from test u where rownum2
4 If paging is performed, for example, there are three rows per page, you need to query the second page, it is equivalent to checking 4, 5, 6 items, starting line 4 = (page number-1) * length of each page + 1, ending line 6 = page number * length of each page
select rownum,id,name from ( select rownum rn , t.* from test t where rownum =4
select rownum,id,name from ( select rownum rn, n.* from ( select * from test --最内层循环该怎么写怎么写 ) n where rownum <=6 --小于限制写在第二层 ) where rn>=4The above content is the basic principle of Oracle paging query, I hope it can help everyone. Related recommendations:
Oracle paging function example implemented in PHP
##php+oracle paging class_PHP tutorialoracle paging query sql principles and statementsThe above is the detailed content of Detailed explanation of the basic principles of Oracle paging query. For more information, please follow other related articles on the PHP Chinese website!

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
