您的位置:首页 > 数据库 > Oracle

Oracle笔记之分页查询

2014-08-09 19:46 309 查看
1、MySQL:

select * from 表名 where 条件 limit 从第几条取,取几条;

2、sql server:

select top 1 * from 表名 where id not in(select top 4 id from 表名 where 条件);

排除前4条,取出一条。

3、Oracle:

select EMP.*,rownum from emp;

rownum 是插入时自动的编号。

select EMP.*,rownum from emp where rownum<=6;

select t1.*,rownum rn from (select * from emp) t1;

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

oracle 使用三层过滤

第一层:select * from EMP;

第二层:select t1.*,rownum rn from (第一层) t1 where rownum<=6;

第三层:select t2.* from(第二层) t2 where rn>=4;

补:只有把一个方法设计的最简单的时候,才能得到最广的应用。

4、以一张存在的表为模板创建一张新表,

create table 表名 as select .......from 表名;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: