Oracle 分页语句,存储过程
select * from (select t.*,rownum rn from (select * from emp) t where rownum<=10) where rn>=6;
创建分页结果集的游标
create or replace package fenyepackage as
type testcursor is ref cursor;
end fenyepackage;
创建分页存储过程
create or replace procedure fenye3(
tableName varchar2, --表名
currPage number, --当前页
currPageSize number, --页大小
countRows out number, --总记录数
countPages out number, --总页数
fenyecursor out fenyepackage.testcursor --当前页结果集
)is
v_sql varchar2(1000);
v_begin number:=(currPage-1)*currPageSize + 1;
v_end number:=currPage*currPageSize;
begin
v_sql:='select * from (select t.*,rownum rn from (select * from '|| tableName ||') t where rownum<='|| v_end ||')
where rn>='||v_begin;
open fenyecursor for v_sql;
v_sql:='select count(*) from '|| tableName;
execute immediate v_sql into countRows;
if mod(countRows,currPageSize)=0 then
countPages:=countRows/currPageSize;
else
countPages:=countRows/currPageSize+1;
end if;
close fenyecursor;
end;
相关文档:
Oracle函数和mysql函数比较
1. Oracle中的to_number()转换成数字;
Oracle> Select to_number(‘123’) from dual; ----- 123;
&nbs ......
mysql 大对象存取:
类型一般应该用mediumblod,
blob只能存2的16次方个byte,
mediumblod是24次方,
一般来说够用了.longblob是32次方有些大.
MYSQL默认配置只能存1M大小的文件,要修改配置,WIN版本的在mysql.ini文件中
修改max_allowed_packet,net_buffer_length等几个参数,或直接SET GLOBAL va ......
数学函数
在oracle 中distinct关键字可以显示相同记录只显示一条
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:select floor(-1.001) value
......
oracle不同版本间数据的导入导出
Oracle的imp/exp组件是我们常用的工具,它的一个操作原则就是向下兼容。下面是据此总结的几个使用规则和相关测试:
规则1:低版本的exp/imp可以连接到高版本(或同版本)的数据库服务器,但高版本的exp/imp不能连接到低版本的数据库服务器
1.1 使用9i客户端通过imp连 ......
限制索引是一些没有经验的开发人员经常犯的错误之一。在SQL中有很多陷阱会使一些索引无法使用。下面讨论一些常见的问题:
1 使用不等于操作符(<>、!=)
下面的查询即使在cust_rating列有一个索引,查询语句仍然执行一次全表扫描。
  ......