Select Mark M to NTD from the Oracle relational database

xiaoxiao2021-03-06  100

I believe that many programmers have encountered such a problem, which is paging display. When you do, anyway, we should not read all the records to the memory. If you choose to record less, you can, if you have 500,000 records in the table? Make sure you will die the best way: I will ask a question first: I really need to support the application of many databases in many times? No, right? If it is true, then you can implement a set of methods, then use the DAO mode to solve the problem of the problem, pull the database to the database! The method of the Oracle / SQLServer / MySQL three databases first out of the first MY-N-N N record: Get in ascending in ascending order according to the F1 field, records from the M to N row, F1 must be indexed or primary keys, preferably Primary key SQL Server SELECT T2. * From (SELECT TOP NM T1. * From (SELECT TOP N * from Tablename As T1 ORDER BY T1.F1 DESC) AS T2 ORDER BY T2.F1 SELECT T2. * From (SELECT TOP 20 T1. * from DBGEN AS TOP 500020 * from DBGEN As TOP 500020 * from DBGEN AS TOORDER BY T.F1) AS T1 Order By T1.f1 DESC) AS T2 Order by T2.f1 Oracle Select * from (SELECT ROWNUM R, T * from Tablename T where r M and T1.R <= m Select * from (SELECT ROWNUM R, T. * from dbtest T where rownum <300020) ss where ss.r> 300000 And ss.r <= 300020 mysql simplest Select * from tablename t ORDER BY T.F1 LIMIT N, M-N 1 Select * from dbtest T ORDER BY T.F1 LIMIT 300000, 20 Performance Comparison: The three are not much! The statement in the above instance is selected from the table of 500,000 records, 20,000 records, no more than 1 second. Other databases I believe you can find almost a way. a

转载请注明原文地址:https://www.9cbs.com/read-126882.html

New Post(0)