- 浏览: 1366020 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (551)
- 计划 (4)
- java (115)
- oracle (60)
- ajax (3)
- javascript (64)
- 计算机操作技巧集 (11)
- 近期关注话题 (10)
- 随想 (13)
- html (6)
- struts (15)
- hibernate (16)
- spring (2)
- game (0)
- Eglish (10)
- DisplayTag (6)
- jsp (18)
- css (3)
- eclipse (3)
- 其他知识 (8)
- 备用1 (12)
- 备用2 (1)
- 笑话-放松心情 (9)
- 设计 (1)
- 设计模式 (1)
- 数据结构 (0)
- office办公软件 (5)
- webwork (0)
- tomcat (2)
- MySql (1)
- 我的链接资源 (5)
- xml (2)
- servlet (0)
- PHP (13)
- DOM (0)
- 网页画图vml,canvas (1)
- 协议 (2)
- 健康 (3)
- 书籍下载 (1)
- jbpm (1)
- EXT (1)
- 自考 (2)
- 报表 (4)
- 生活 (64)
- 操作系统基础知识 (2)
- 测试 (2)
- guice (1)
- google学习 (2)
- Erlang (1)
- LOG4J (2)
- wicket (1)
- 考研 (1)
- 法律 (1)
- 地震 (1)
- 易学-等等相关 (1)
- 音乐 (1)
- 建站 (4)
- 分享说 (3)
- 购物省钱 (0)
- linux (1)
最新评论
-
zenmshuo:
如果使用SpreadJS这一类的表格工具,应该能更好的实现这些 ...
js中excel的用法 -
hjhj2991708:
第一个已经使用不了
jar包查询网站 非常好用! -
jiangmeiwei:
...
中文乱码 我的总结 不断更新 -
gary_bu:
...
response.sendRedirect 中文乱码问题解决 -
hnez:
多谢指点,怎么调试也不通,原来我在<body>&l ...
ExtJs IE ownerDocument.createRange() 错误解决方案
原文:http://tech.ccidnet.com/art/1105/20080105/1332111_1.html
Oracle与DB2、MySQL取前10条记录的对比 (1)
发布时间:2008.01.07 09:16 来源:赛迪网 作者:10027
Oralce的示例:
1. 最佳选择:利用分析函数
row_number() over ( partition by col1 order by col2 )
比如想取出100-150条记录,按照tname排序
2. 使用rownum 虚列
注释:使用序列时不能基于整个记录集合来进行排序,假如指定了order by子句,排序的的是选出来的记录集的排序。
(1) 取前10条不同id记录,假如最后1条记录的ID依然有相同的,那么取出来。
(2)取前10条记录,假如第10条记录的ID 还有相同的,那么取出来。
(3)取前10条记录
Db2示例
create table mynumber(id int,name varchar(10))
insert into mynumber values(1,'no1')
insert into mynumber values(2,'no2')
insert into mynumber values(3,'no3')
insert into mynumber values(4,'no4')
insert into mynumber values(5,'no5')
insert into mynumber values(5,'no6')
insert into mynumber values(6,'no7')
insert into mynumber values(7,'no8')
insert into mynumber values(8,'no9')
insert into mynumber values(9,'no10')
insert into mynumber values(9,'no11')
insert into mynumber values(9,'no12')
insert into mynumber values(10,'no13')
insert into mynumber values(10,'no14')
insert into mynumber values(10,'no15')
insert into mynumber values(11,'no16')
insert into mynumber values(12,'no17')
insert into mynumber values(13,'no18')
select * from (select id,name,RANK() over
( order by id ) case1,DENSE_RANK() over
( order by id ) case2,row_number() over
( order by id ) case3 from mynumber) as tt where case1<=10
(1) 取前10条不同id记录,假如最后1条记录的ID依然有相同的,那么全部取出来。
select * from mynumber where id in
(select distinct id from mynumber fetch first 10 rows only)
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case1<=10
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case1 between 5 and 10
(2)取前10条记录,假如第10条记录的ID 还有相同的,那么全部取出来。
select * from mynumber where id in
(select id from mynumber fetch first 10 rows only)
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case2<=10
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case2 between 5 and 10
(3)取前10条记录
select id from mynumber fetch first 10 rows only
select * from (select id,name,RANK() over
( order by id ) case1,DENSE_RANK() over
( order by id ) case2,row_number() over
( order by id ) case3 from mynumber) as tt where case3<=10
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case3 between 5 and 10
Mysql示例:
select id from mytable order by update_date desc limit 0,10
Oracle与DB2、MySQL取前10条记录的对比 (1)
发布时间:2008.01.07 09:16 来源:赛迪网 作者:10027
Oralce的示例:
1. 最佳选择:利用分析函数
row_number() over ( partition by col1 order by col2 )
比如想取出100-150条记录,按照tname排序
select tname,tabtype from ( select tname,tabtype,row_number() over ( order by tname ) rn from tab ) where rn between 100 and 150;
2. 使用rownum 虚列
select tname,tabtype from ( select tname,tabtype,rownum rn from tab where rownum <= 150 ) where rn >= 100;
注释:使用序列时不能基于整个记录集合来进行排序,假如指定了order by子句,排序的的是选出来的记录集的排序。
create table mynumber(id int,name varchar(10)); insert into mynumber values(1,'no1'); insert into mynumber values(2,'no2'); insert into mynumber values(3,'no3'); insert into mynumber values(4,'no4'); insert into mynumber values(5,'no5'); insert into mynumber values(5,'no6'); insert into mynumber values(6,'no7'); insert into mynumber values(7,'no8'); insert into mynumber values(8,'no9'); insert into mynumber values(9,'no10'); insert into mynumber values(9,'no11'); insert into mynumber values(9,'no12'); insert into mynumber values(10,'no13'); insert into mynumber values(10,'no14'); insert into mynumber values(10,'no15'); insert into mynumber values(11,'no16'); insert into mynumber values(12,'no17'); insert into mynumber values(13,'no18'); select id,name,RANK() over ( order by id ) case1, DENSE_RANK() over ( order by id ) case2, row_number() over ( order by id ) case3 from mynumber;
(1) 取前10条不同id记录,假如最后1条记录的ID依然有相同的,那么取出来。
select id,name from mynumber where id in (select id from (select distinct id from mynumber) tt where rownum<=10); select * from (select id,name,RANK() over ( order by id ) case1,DENSE_RANK() over ( order by id ) case2,row_number() over ( order by id ) case3 from mynumber) tt where case1<=10; select * from (select id,name,RANK() over ( order by id ) case1,DENSE_RANK() over ( order by id ) case2,row_number() over ( order by id ) case3 from mynumber) tt where case1 between 5 and 10;
(2)取前10条记录,假如第10条记录的ID 还有相同的,那么取出来。
select * from mynumber where id in (select id from mynumber where rownum <=10); select * from (select id,name,RANK() over ( order by id ) case1,DENSE_RANK() over ( order by id ) case2,row_number() over ( order by id ) case3 from mynumber) tt where case2<=10; select * from (select id,name,RANK() over ( order by id ) case1,DENSE_RANK() over ( order by id ) case2,row_number() over ( order by id ) case3 from mynumber) tt where case2 between 5 and 10;
(3)取前10条记录
select id,name from mynumber where rownum <=10; select id,name from (select id,name,rownum rn from mynumber where rownum <= 10 ) where rn >= 5; select * from (select id,name,RANK() over ( order by id ) case1,DENSE_RANK() over ( order by id ) case2,row_number() over ( order by id ) case3 from mynumber) tt where case3<=10; select * from (select id,name,RANK() over ( order by id ) case1,DENSE_RANK() over ( order by id ) case2,row_number() over ( order by id ) case3 from mynumber) tt where case3 between 5 and 10;
Db2示例
create table mynumber(id int,name varchar(10))
insert into mynumber values(1,'no1')
insert into mynumber values(2,'no2')
insert into mynumber values(3,'no3')
insert into mynumber values(4,'no4')
insert into mynumber values(5,'no5')
insert into mynumber values(5,'no6')
insert into mynumber values(6,'no7')
insert into mynumber values(7,'no8')
insert into mynumber values(8,'no9')
insert into mynumber values(9,'no10')
insert into mynumber values(9,'no11')
insert into mynumber values(9,'no12')
insert into mynumber values(10,'no13')
insert into mynumber values(10,'no14')
insert into mynumber values(10,'no15')
insert into mynumber values(11,'no16')
insert into mynumber values(12,'no17')
insert into mynumber values(13,'no18')
select * from (select id,name,RANK() over
( order by id ) case1,DENSE_RANK() over
( order by id ) case2,row_number() over
( order by id ) case3 from mynumber) as tt where case1<=10
(1) 取前10条不同id记录,假如最后1条记录的ID依然有相同的,那么全部取出来。
select * from mynumber where id in
(select distinct id from mynumber fetch first 10 rows only)
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case1<=10
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case1 between 5 and 10
(2)取前10条记录,假如第10条记录的ID 还有相同的,那么全部取出来。
select * from mynumber where id in
(select id from mynumber fetch first 10 rows only)
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case2<=10
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case2 between 5 and 10
(3)取前10条记录
select id from mynumber fetch first 10 rows only
select * from (select id,name,RANK() over
( order by id ) case1,DENSE_RANK() over
( order by id ) case2,row_number() over
( order by id ) case3 from mynumber) as tt where case3<=10
select * from (select id,name,RANK()
over ( order by id ) case1,DENSE_RANK()
over ( order by id ) case2,row_number()
over ( order by id ) case3 from mynumber)
as tt where case3 between 5 and 10
Mysql示例:
select id from mytable order by update_date desc limit 0,10
发表评论
-
oracle删除重复记录
2009-07-16 11:16 1216有困难,找猪八戒 Q:要删除一张表中的重复记录,但是要保留一条 ... -
db2 express-c 安装后检查及安装例子数据库
2009-02-27 17:07 3396摘自http://publib.boulder.ibm.com ... -
问:如何得到与WEB-INF同级目录下的配置文件
2008-09-23 08:35 2137Q: 有如下需求:需要从WEB-INF同级的目录下读取配 ... -
讨论如何优化这条sql
2008-09-11 16:33 1600SELECT * FROM ( ... -
N Vs Exist in SQL
2008-07-02 16:39 1394N Vs Exist in SQL 原文如下: http:// ... -
SQL 指南
2008-05-27 11:45 1047http://www.sql-tutorial.com/ -
orace 分析函数
2008-05-26 09:08 1214select x.num, sum(x.num) over ( ... -
oralce tutoial 指南
2008-03-22 14:21 1033http://www.exforsys.com/tutoria ... -
查找部分字段重复的记录 ORACLE Identifying duplicate rows
2008-03-13 08:49 1968http://www.jlcomp.demon.co.uk/f ... -
oracle 资源网站
2008-01-12 11:42 1880oracle alter table table_ ... -
Top 5 Oracle Reference Books 前5本 oracle 参考书
2008-01-12 11:24 1721http://databases.about.com/od/o ... -
expert on e on one oracle - Thomas Kyte 读书笔记
2008-01-11 10:17 2112=============================== ... -
oracle 资源 整体理解oralce 比较好 英文网
2008-01-09 16:59 1200http://www.adp-gmbh.ch/ora/admi ... -
oracle java 插入 clob insert clob hibernate
2007-12-21 15:48 7232用jdbc 或者 hibernate http://www.w ... -
pl/sql 应用之一
2007-12-12 17:21 1143declare begin insert into x ... -
init.ora文件所在目录
2007-12-12 15:58 2167Oracle安装盘:\oracle\admin\DB名称\pf ... -
[Oracle] 如何解决ORA-04031 错误
2007-12-12 15:53 3254[Oracle] 如何解决ORA-04031 ... -
oracle faq 常见问题解答 http://www.orafaq.com/
2007-12-12 13:34 1499The Oracle FAQ http://www.oraf ... -
oracle 快速参考
2007-12-12 09:58 1095http://www.psoug.org/library.ht ... -
oracle like
2007-12-12 09:18 3417http://www.adp-gmbh.ch/ora/sql/ ...
相关推荐
本知识点将详细介绍如何使用JDBC与MySQL、Oracle、DB2等数据库进行连接,并涉及所需的JAR包驱动。 首先,JDBC是一个Java API,允许Java应用程序与各种类型的数据库进行交互。为了实现这一功能,我们需要对应的...
DB2 173<br>6.3.1 进行安装 174<br>6.3.2 检验安装 180<br>6.4 配置Control Center 182<br>6.5 安装DB2客户机 184<br>6.6 配置DB2客户机与DB2服务器通信 188<br>6.7 小结 194<br>6.8 常见问答 195<br>第7章 在Linux...
<br>Support databases like HSQLDB, MySQL, PostgreSQL, Oracle, DB2 etc. <br>Multi-languages(English/Chinese...) <br>Fully customizable templates <br>Categories <br>Comments <br>Files upload <br>RSS ...
jdbc:mysql://<machine_name>:<port>/<dbname> ``` 其中: - `<machine_name>` 是数据库服务器的主机名或 IP 地址。 - `<port>` 是 MySQL 服务监听的端口,默认通常是 3306。 - `<dbname>` 是要连接的数据库...
servers: Centura (formerly, Gupta) SQLBase Server <br>IBM DB2 Universal Database <br>Informix Server <br>Interbase/Firebird Server <br>Microsoft SQL Server <br>MySQL Server <br>Oracle Database Server ...
<Driver>oracle.jdbc.driver.OracleDriver</Driver> <Url>jdbc:oracle:thin:@10.16.1.88:1521:nwom</Url> <User>custcare</User> <Password>custcare</Password> </DBInfo> ``` - **id**:唯一标识符,用于在...
1.<br>支持多数据库,如db2、ms-sqlserver、oracle(准备在下个版本加入access和mysql,由于最近写这个实在是累,等找到工作再增加预告的功能吧);<br>2.<br>支持语法高亮显示,由于采用的是QCTextEditor(一个比较...
理论上支持MySQL、SQLite、Oracle、FreeTDS、Microsoft SQL Server、Sybase、IBM DB2、ODBC、PostgreSQL<br>14、无缝整合phpwind与Discuz,更多论坛接口正在紧加开发中<br>15、带有用户插件接口,提供更方便的第三方...
迁移过程中,需要关注两个系统之间的数据类型差异,例如MySQL的VARBINARY与Oracle的BLOB,或者MySQL的ENUM与Oracle的CHAR/VARCHAR2。此外,还需要考虑事务处理、触发器、存储过程等高级特性在迁移过程中的转换,以及...
<br> <br> 5、提供了快速生成某些常用SQL语句(如多种数据库系统的前N条记录)的功能。<br> <br> 6、提供了执行多条SQL语句的支持;<br> <br> 7、提供了对执行的一批SQL语句中每条SQL语句执行时间的记录,使用户更...
X3-BLOG 是基于XML+XSLT+AJAX技术构建的开源多用户博客门户系统,服务器端采用当前最流行的动态网页开发语言ASP.NET(C#) <br><br>2.0编写,支持多种数据库,包括SQLSERVER2000\SQLSERVER2005\ORACLE\MYSQL\DB2\...
BLOG<br><br> X3-BLOG 是基于XML+XSLT+AJAX技术构建的开源多用户博客门户系统,服务器端采用当前最流行的动态网页开发语言之一ASP.NET(C#) 2.0编写,支持多种数据库,包括SQLSERVER2000\SQLSERVER2005\ORACLE\MYSQL\...
总结来说,"JDBC_oracle+mysql+db2"这个压缩包包含了与Oracle、MySQL和DB2数据库交互所需的JDBC驱动,它们是Java开发者连接这三种数据库的重要工具。正确理解和使用这些驱动,能够帮助开发者高效地实现数据库操作,...
Oracle、DB2和MySQL是三种非常流行的数据库管理系统,广泛应用于企业级应用、数据分析以及互联网服务。Java作为一种多平台支持的编程语言,常常被用来与这些数据库进行交互。本篇将详细介绍这三种数据库的驱动以及...
它支持多种数据库,包括h2、mysql、oracle和db2等。可以通过maven依赖引入Activiti运行所需的jar包。开发环境推荐使用Eclipse 3.7或以上版本,以及MyEclipse 8.6版本。 接下来,需要安装流程设计器(Activiti ...
<url>jdbc:mysql://<host>:<port>/<database></url> <user-name><username></user-name> <password><password></password> ``` - `<host>`: MySQL所在计算机的主机名。 - `<port>`: MySQL服务端口号,默认为...
-- value="mssql|oracle|mysql|db2" --> <properties> <property name="dialect" value="mssql" /> </properties> <plugins> <plugin interceptor="com.gian.commons.dialect.PaginationInterceptor" /> ...
- **重做日志文件(RedoLogFiles)**与**事务日志文件(TransactionLogFiles)**:Oracle的重做日志记录了所有修改数据库的事务,DB2使用事务日志记录类似的信息。 - **PL/SQL与SQL/PL**:Oracle使用PL/SQL作为过程...
这个"oracle、db2、informix数据库的jdbc包"包含的就是这三个数据库的JDBC驱动程序,使得Java开发者能够方便地与这些数据库进行交互。 1. **Oracle JDBC驱动**:Oracle数据库提供了多种JDBC驱动类型,包括 Thin、...