CREATE TABLE SCOTT.S1_Score
(
ID NUMBER(10),
Score NUMBER(3),
Name VARCHAR2(10)
)
(
ID NUMBER(10),
Score NUMBER(3),
Name VARCHAR2(10)
)
CREATE TABLE SCOTT.S2_Score
(
ID NUMBER(10),
Score NUMBER(3),
Name VARCHAR2(10)
)
(
ID NUMBER(10),
Score NUMBER(3),
Name VARCHAR2(10)
)
CREATE TABLE SCOTT.Y2_Score
(
ID NUMBER(10),
Score NUMBER(3),
Name VARCHAR2(10),
Descr VARCHAR2(10)
)
(
ID NUMBER(10),
Score NUMBER(3),
Name VARCHAR2(10),
Descr VARCHAR2(10)
)
insert into S1_Score(ID,Score,Name) values(1,80,'张三')
create sequence seq_y2score
start 1000
increment by 1
start 1000
increment by 1
select seq_score.nextval from dual
select seq_score.currval from dual
select seq_score.currval from dual
insert into S1_Score(ID,Score,Name) values(seq_score.nextval ,80,'张三')
insert into S2_Score(ID,Score,Name) values(seq_score.nextval ,80,'张三')
insert into S2_Score(ID,Score,Name) values(seq_y2score.nextval ,80,'张三')
insert into S2_Score(ID,Score,Name) values(5 ,80,'张三')
insert into S2_Score(ID,Score,Name) values(seq_score.nextval ,80,'张三')
insert into S2_Score(ID,Score,Name) values(seq_y2score.nextval ,80,'张三')
insert into S2_Score(ID,Score,Name) values(5 ,80,'张三')
insert into S2_Score(ID,Score,Name)
values(seq_score.nextval ,seq_y2score.nextval,'张三')
values(seq_score.nextval ,seq_y2score.nextval,'张三')
select a.empno, rowid rid,rownum from emp a
select * from emp where rowid='AAAH14AABAAAO+HAAI'
select *,rownum from emp
select empno,ename,rownum from emp where ename>='K'
select empno,ename,rownum from emp where ename>='K' order by ename
select empno,ename,rownum from emp where ename>='K'
select empno,ename,rownum from emp where ename>='K' order by ename
第一页:允许有限制条件
select * from emp where rownum<=3
select * from emp where ename>='K' and rownum<=3
select * from emp where rownum<=3
select * from emp where ename>='K' and rownum<=3
//错误,先取一页,在一页中排序
select * from emp where ename>='K' and rownum<=3 order by ename
正确,有排序的时候,查询第一页
select a.* from (
select * from emp where ename>='K' order by ename) a
where rownum<=3
select * from emp where ename>='K' and rownum<=3 order by ename
正确,有排序的时候,查询第一页
select a.* from (
select * from emp where ename>='K' order by ename) a
where rownum<=3
第2,3,4页:允许有限制条件
select * from emp where rownum<=6 and rownum>3//错误
select * from emp where rownum=1//正确
select * from emp where rownum=2//错误
select * from emp where rownum>3//错误
select * from emp where rownum<=6 and rownum>3//错误
select * from emp where rownum=1//正确
select * from emp where rownum=2//错误
select * from emp where rownum>3//错误
select * from
(select a.*, rownum rn from emp a where rownum<=9)
where rn>6
(select a.*, rownum rn from emp a where rownum<=9)
where rn>6
select * from
(select a.*, rownum rn from emp a where ename>='K' and rownum<=9)
where rn>6
(select a.*, rownum rn from emp a where ename>='K' and rownum<=9)
where rn>6
//错误,先取一页,在一页中排序
select * from
(select a.*, rownum rn from emp a where ename>='K' and rownum<=9 order by ename)
where rn>6
select * from
(select a.*, rownum rn from emp a where ename>='K' and rownum<=9 order by ename)
where rn>6
正确,有排序的时候,查询第2,3,4页
select * from (
select a.*,rownum rn from (
select * from emp where ename>='K' order by ename) a
where rownum<=6) where rn>3
版权说明
如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
作 者:温景良
文章出处:http://wenjl520.cnblogs.com/ 或 http://www.cnblogs.com/
公告
本文转自我的程序人生博客园博客,原文链接:http://www.cnblogs.com/wenjl520/archive/2009/04/28/1445766.html,如需转载请自行联系原作者
【推荐】腾讯云新用户域名抢购1元起,抓紧抢购
· 精准率首次超过人类!阿里巴巴机器阅读理解打破世界纪录
· 技术帖:每天被今日头条推送文章 背后的算法技术是什么?
· 支付宝实体版老黄历问世:全球限量1000册
· 趣店被蚂蚁金服送上纽交所,现在是时候该独立了
· 蚂蚁宝卡升级:支付宝/微博即将免流
» 更多新闻...
· 以操作系统的角度述说线程与进程
· 软件测试转型之路
· 门内门外看招聘
· 大道至简,职场上做人做事做管理