易截截图软件、单文件、免安装、纯绿色、仅160KB

Oracle、SQL Server、Access数据库高效果分页技巧

 在程序的开发过程中,处理分页是大家接触比较频繁的事件,因为现在软件基本上都是与数据库进行挂钓的。但效率又是我们所追求的,如果是像原来那样把所有满足条件的记录全部都选择出来,再去进行分页处理,那么就会多多的浪费掉许多的系统处理时间。为了能够把效率提高,所以现在我们就只选择我们需要的数据,减少数据库的处理时间,以下就是常用SQL分页处理:
  1、SQL Server、Access数据库
  这都微软的数据库,都是一家人,基本的操作都是差不多,常采用如下分页语句:
  PAGESIZE:每页显示的记录数
  CURRENTPAGE:当前页号
  数据表的名字是:components
  索引主键字是:id
以下是引用片段:
  select top PAGESIZE * from components where id not in
  (select top (PAGESIZE*(CURRENTPAGE-1))
  id from components order by id)order by id
  如下列:
以下是引用片段:
  select top 10 * from components where id not in
  (select top 10*10 id from components order by id)
  order by id
  从101条记录开始选择,只选择前面的10条记录
  2、Oracle数据库
  因为Oracle数据库没有Top关键字,所以这里就不能够像微软的数据据那样操作,这里有两种方法:
  (1)、一种是利用相反的。
  PAGESIZE:每页显示的记录数
  CURRENTPAGE:当前页号
  数据表的名字是:components
  索引主键字是:id
以下是引用片段:
  select * from components where id not
  in(select id from components where
  rownum<=(PAGESIZE*(CURRENTPAGE-1)))
  and rownum<=PAGESIZE order by id;
  如下例:
以下是引用片段:
  select * from components where id not in
  (select id from components where rownum<=100)
  and rownum<=10 order by id;
  从101到记录开始选择,选择前面10条。
  (2)、使用minus,即中文的意思就是减去。
以下是引用片段:
  


相关文档:

Oracle 几个服务各代表什么作用?

转载自 http://hi.baidu.com/libinichen/blog/item/9e13ac31175877a95edf0e0b.html
注:SID - 数据库标识
HOME_NAME - Oracle Home名称,如OraHome92、OraHome81
(1)OracleServiceSID
数据库服务,这个服务会自动地启动和停止数据库。如果安装了一个数据库,它的缺省启动类型为自动。服务进程为ORACLE.EXE,参数文件 ......

[Oracle] 重新分析表使数据库自动压缩表。

oracle11g具有自动的表压缩功能, 但当insert语句未指定具体的列名时, 会使用自动表压缩功能失效。(如该语句会使得表t_test不能自动压缩: insert into t_test select * from t_test2)
另外使用一些外部工具进行数据装载(sqlload),也有可能使得表不能自动压缩,此时需要用以下语句,以重新分析表,分析完成之后,该表即会 ......

SQL语句PART3

constraint Example:
1. grammer:
 create table [schema.]table
      (column datatype [DEFAULT expr]
     [column_constraint], ...
     [table_constraint] [,......]);
2. example of a column_level constraint:
create table empl ......

SQL语句PART7

Merge statement
function benefits: 1) provides the ability to conditionally update, insert or delete data into a database table. 2) performs an update if the row exists, and an insert if it is a new row. --> 1) avoids seperate updates, 2) increase performance and ease of use. 3) is useful in dat ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号