Oracle分頁查詢

2021-09-06 06:38:52 字數 1320 閱讀 8140

********************=

mysql

********************=

select * from table_name limit 從第幾條取,取幾條

********************=

sql server

********************=

select top 4 * from 表名 where not in(select top 4 * from 表名 where 條件);

排除前4條,再取4條

********************=

oracle

********************=

--第一層

select * from emp;

--第二層

select t1.*,rownum rn from (select * from emp) t1 where rownum<=12;

--第三層

select t2.* from (select t1.*,rownum rn from (select * from emp) t1 where rownum<=10) t2 where t2.rn>=6;

int startindex; 開始位置

int pagesize; 取的條數

select t2.* from (select t1.*,rownum rn from (select * from emp) t1 where rownum<=(startindex*pagesize)) t2 where t2.rn>=((startindex-1)*pagesize+1);

測試:--建立新錶查入另一張表的資料

create table mytest as select empno,ename,job,sal,comm from emp;

--自我賦值資料[多次執行]

insert into mytest(empno,ename,job,sal,comm) select * from mytest;

select t2.* from (select t1.*,rownum rn from (select * from emp) t1 where rownum<=10) t2 where t2.rn>=6;

select t2.* from (select t1.*,rownum rn from (select * from emp) t1 where rownum<=300010) t2 where t2.rn>=300000;

分別檢視所執行的時間

ORACLE分頁查詢

單錶分頁 start num 起始行號 end num 截止行號 select t.from select s.rownum rn from table s where rownum end num t where rn start num 多表分頁 select from select temp....

Oracle分頁查詢

oracle的分頁查詢語句基本上可以按照本文給出的格式來進行套用。分頁查詢格式 select from select a.rownum rn from select from table name a where rownum 40 where rn 21 其中最內層的查詢select from t...

oracle 分頁查詢

1 要把rowid來分 select from t xiaoxi where rowid in select rid from select rownum rn,rid from select rowid rid,cid from t xiaoxi order by cid desc where r...