日期:2014-05-16  浏览次数:20387 次

oracle 分页笔记

?

-- pageIndex  表示第几页
-- pageSize   表示每页页示的总条数
/**
   这段SQL语句的意思是:
   先查询当前索引*每页显示的总条数据,
   然后再从里面去掉前面查询的数据,并截取查询下一页要显示的数据
*/
 select * from (select rownum as r, t.* from(select * from house)t
  where rownum<=pageIndex*pageSize) where r>(pageIndex-1)*pageSize   
  
 select * from (select rownum as r, t.* from(select * from student)t 
 where rownum<=3000*3) where r>(3000-1)*3    

--再加个循环笔记
declare i int;
 begin
     i:=0;
  loop 
     i:=i+1;
      insert into student 
      values(Seq_Student_Id.Nextval,'testYY'||i,'male'); 
       commit;
     
      if i>10000 then
      exit;
      end if;
   end loop; 
           Exception
      when others then 
      rollback; 
     
 end ;

--oracle循环语句学习网址
http://www.cnblogs.com/zheng8145/archive/2008/12/02/1345930.html