存档
1. Oracle发展历史
Java数据库连接(JDBC)由一组用 Java 编程语言编写的类和接口组成。JDBC 为工具/数据库开发人员提供了一个标准的 API,使他们能够用纯Java API 来编写数据库应用程序。然而各个开发商的接口并不完全相同,所以开发环境的变化会带来一定的配置变化。本文主要集合了不同数据库的连接方式。
一、连接各种数据库方式速查表
下面罗列了各种数据库使用JDBC连接的方式,可以作为一个手册使用。
1、Oracle8/8i/9i数据库(thin模式)
Java代码
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);
2、DB2数据库
Java代码
Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();
String url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
目前B/S架构的软件大行其道。通过浏览器如何向终端用户只展示指定页面内容而不是全部的?毕竟返回全部结果集,时间和空间开销都很大。
如此情况下,对SQL返回结果集进行分页是个很不错的解决方案。
本文主要介绍MySQL数据库中的分页实现方式。我以一个数据库管理员的角度进行说明,至于具体的实现还需要开发人员详细编写过程。
总的说来,在MySQL中实现分页功能是很简单的事情。MySQL数据库的开发人员替广大的使用者着想,提供了一个关键字limit来实现限定指定范围的功能。
下面简单介绍分页的思路。
在MySQL5.0.15-nt-max下进行测试。
1.新建一张临时表(MyISAM或者InnoDB类型的都可以),本测试表没有使用自增列。
CREATE TABLE `andkylee` (
`id` int(11) NOT NULL,
`name` varchar(30) default NULL,
`sex` char(1) NOT NULL,
`age` smallint(6) default NULL,
`note` varchar(100) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
2.插入测试数据。 在这里尤其介绍一种插入大量测试数据的方法。
先插入2条数据:
insert into andkylee
values(1,'hanyuliu','F',25,'aaaaaaaaaa'),(2,'andkylee','F',33,'bbbbbbbbbb');
批量插入数据:
在没有自增列的情况下,用下面的语句来实现插入“重复”数据。
insert into andkylee
select id+(select max(id) from andkylee),name,sex,age,note from andkylee;
本语句能够复制表已有的所有记录,并且能够实现“主键列”自增。
可能有点缺陷的是:需要再select列表中逐个写出各个列名。但是,好像含有自增列的表为了实现插入重复数据,也必须把非自增列都写出来吧。 如果我说的不对,请告知。
循环插入重复数据,使得表数据行数以指数方式增长。 再把已有的数据插入到表内,行数变为以前的2倍。
insert into andkylee
select id+(select max(id) from andkylee),name,sex,age,note from andkylee;
mysql> select count(*) from andkylee;
+----------+
| count(*) |
+----------+
| 4 |
+----------+
1 row in set (0.05 sec)
重复上面的语句,执行10次之后,表内的数据行数为:2048
测试数据情况为:
mysql> select *from andkylee;
+------+----------+-----+------+------------+
| id | name | sex | age | note |
+------+----------+-----+------+------------+
| 1 | hanyuliu | F | 25 | aaaaaaaaaa |
| 2 | andkylee | F | 33 | bbbbbbbbbb |
| 3 | hanyuliu | F | 25 | aaaaaaaaaa |
| 4 | andkylee | F | 33 | bbbbbbbbbb |
.....
| 2043 | hanyuliu | F | 25 | aaaaaaaaaa |
| 2044 | andkylee | F | 33 | bbbbbbbbbb |
| 2045 | hanyuliu | F | 25 | aaaaaaaaaa |
| 2046 | andkylee | F | 33 | bbbbbbbbbb |
| 2047 | hanyuliu | F | 25 | aaaaaaaaaa |
| 2048 | andkylee | F | 33 | bbbbbbbbbb |
+------+----------+-----+------+------------+
2048 rows in set (0.08 sec)
3.选择第100至300行数据
这里不得不介绍limit这个关键字了。
limit关键字的使用方式为:
(SQL statement) limit row_position,row_count
其中:(SQL statement) 为完整的SQL语句,就是普通的sql语句,以前的语句该怎么写的还是怎么写。
limit 是个关键字,在MySQL中关键字是不区分大小写的,Limit,limit,LIMIT对于数据库引擎来说都是一样的。
后面是两个参数,row_position表示起始行,更确切的说应该是偏移行,自然row_position是从0开始的。也就是说第一行的偏移行数为0.
要是想返回从第二行开始的记录,就将row_position指定为1.
第二个参数:row_count表示返回的行数。 这个很简单,不赘述。
因此,要返回第100至300行数据,需要指定偏移行号为99,并且行数为201.
语句为:
select *from andkylee LimiT 99,201;
返回结果为:
mysql> select *from andkylee LimiT 99,201;
+-----+----------+-----+------+------------+
| id | name | sex | age | note |
+-----+----------+-----+------+------------+
| 100 | andkylee | F | 33 | bbbbbbbbbb |
| 101 | hanyuliu | F | 25 | aaaaaaaaaa |
| 102 | andkylee | F | 33 | bbbbbbbbbb |
| 103 | hanyuliu | F | 25 | aaaaaaaaaa |
| 104 | andkylee | F | 33 | bbbbbbbbbb |
| 105 | hanyuliu | F | 25 | aaaaaaaaaa |
| 106 | andkylee | F | 33 | bbbbbbbbbb |
| 107 | hanyuliu | F | 25 | aaaaaaaaaa |
| 108 | andkylee | F | 33 | bbbbbbbbbb |
| 109 | hanyuliu | F | 25 | aaaaaaaaaa |
| 110 | andkylee | F | 33 | bbbbbbbbbb |
| 111 | hanyuliu | F | 25 | aaaaaaaaaa |
| 112 | andkylee | F | 33 | bbbbbbbbbb |
| 113 | hanyuliu | F | 25 | aaaaaaaaaa |
| 114 | andkylee | F | 33 | bbbbbbbbbb |
| 115 | hanyuliu | F | 25 | aaaaaaaaaa |
| 116 | andkylee | F | 33 | bbbbbbbbbb |
| 117 | hanyuliu | F | 25 | aaaaaaaaaa |
| 118 | andkylee | F | 33 | bbbbbbbbbb |
| 119 | hanyuliu | F | 25 | aaaaaaaaaa |
| 120 | andkylee | F | 33 | bbbbbbbbbb |
| 121 | hanyuliu | F | 25 | aaaaaaaaaa |
| 122 | andkylee | F | 33 | bbbbbbbbbb |
| 123 | hanyuliu | F | 25 | aaaaaaaaaa |
| 124 | andkylee | F | 33 | bbbbbbbbbb |
| 125 | hanyuliu | F | 25 | aaaaaaaaaa |
| 126 | andkylee | F | 33 | bbbbbbbbbb |
| 127 | hanyuliu | F | 25 | aaaaaaaaaa |
| 128 | andkylee | F | 33 | bbbbbbbbbb |
| 129 | hanyuliu | F | 25 | aaaaaaaaaa |
| 130 | andkylee | F | 33 | bbbbbbbbbb |
| 131 | hanyuliu | F | 25 | aaaaaaaaaa |
| 132 | andkylee | F | 33 | bbbbbbbbbb |
| 133 | hanyuliu | F | 25 | aaaaaaaaaa |
| 134 | andkylee | F | 33 | bbbbbbbbbb |
| 135 | hanyuliu | F | 25 | aaaaaaaaaa |
| 136 | andkylee | F | 33 | bbbbbbbbbb |
| 137 | hanyuliu | F | 25 | aaaaaaaaaa |
| 138 | andkylee | F | 33 | bbbbbbbbbb |
| 139 | hanyuliu | F | 25 | aaaaaaaaaa |
| 140 | andkylee | F | 33 | bbbbbbbbbb |
| 141 | hanyuliu | F | 25 | aaaaaaaaaa |
| 142 | andkylee | F | 33 | bbbbbbbbbb |
| 143 | hanyuliu | F | 25 | aaaaaaaaaa |
| 144 | andkylee | F | 33 | bbbbbbbbbb |
| 145 | hanyuliu | F | 25 | aaaaaaaaaa |
| 146 | andkylee | F | 33 | bbbbbbbbbb |
| 147 | hanyuliu | F | 25 | aaaaaaaaaa |
| 148 | andkylee | F | 33 | bbbbbbbbbb |
| 149 | hanyuliu | F | 25 | aaaaaaaaaa |
| 150 | andkylee | F | 33 | bbbbbbbbbb |
| 151 | hanyuliu | F | 25 | aaaaaaaaaa |
| 152 | andkylee | F | 33 | bbbbbbbbbb |
| 153 | hanyuliu | F | 25 | aaaaaaaaaa |
| 154 | andkylee | F | 33 | bbbbbbbbbb |
| 155 | hanyuliu | F | 25 | aaaaaaaaaa |
| 156 | andkylee | F | 33 | bbbbbbbbbb |
| 157 | hanyuliu | F | 25 | aaaaaaaaaa |
| 158 | andkylee | F | 33 | bbbbbbbbbb |
| 159 | hanyuliu | F | 25 | aaaaaaaaaa |
| 160 | andkylee | F | 33 | bbbbbbbbbb |
| 161 | hanyuliu | F | 25 | aaaaaaaaaa |
| 162 | andkylee | F | 33 | bbbbbbbbbb |
| 163 | hanyuliu | F | 25 | aaaaaaaaaa |
| 164 | andkylee | F | 33 | bbbbbbbbbb |
| 165 | hanyuliu | F | 25 | aaaaaaaaaa |
| 166 | andkylee | F | 33 | bbbbbbbbbb |
| 167 | hanyuliu | F | 25 | aaaaaaaaaa |
| 168 | andkylee | F | 33 | bbbbbbbbbb |
| 169 | hanyuliu | F | 25 | aaaaaaaaaa |
| 170 | andkylee | F | 33 | bbbbbbbbbb |
| 171 | hanyuliu | F | 25 | aaaaaaaaaa |
| 172 | andkylee | F | 33 | bbbbbbbbbb |
| 173 | hanyuliu | F | 25 | aaaaaaaaaa |
| 174 | andkylee | F | 33 | bbbbbbbbbb |
| 175 | hanyuliu | F | 25 | aaaaaaaaaa |
| 176 | andkylee | F | 33 | bbbbbbbbbb |
| 177 | hanyuliu | F | 25 | aaaaaaaaaa |
| 178 | andkylee | F | 33 | bbbbbbbbbb |
| 179 | hanyuliu | F | 25 | aaaaaaaaaa |
| 180 | andkylee | F | 33 | bbbbbbbbbb |
| 181 | hanyuliu | F | 25 | aaaaaaaaaa |
| 182 | andkylee | F | 33 | bbbbbbbbbb |
| 183 | hanyuliu | F | 25 | aaaaaaaaaa |
| 184 | andkylee | F | 33 | bbbbbbbbbb |
| 185 | hanyuliu | F | 25 | aaaaaaaaaa |
| 186 | andkylee | F | 33 | bbbbbbbbbb |
| 187 | hanyuliu | F | 25 | aaaaaaaaaa |
| 188 | andkylee | F | 33 | bbbbbbbbbb |
| 189 | hanyuliu | F | 25 | aaaaaaaaaa |
| 190 | andkylee | F | 33 | bbbbbbbbbb |
| 191 | hanyuliu | F | 25 | aaaaaaaaaa |
| 192 | andkylee | F | 33 | bbbbbbbbbb |
| 193 | hanyuliu | F | 25 | aaaaaaaaaa |
| 194 | andkylee | F | 33 | bbbbbbbbbb |
| 195 | hanyuliu | F | 25 | aaaaaaaaaa |
| 196 | andkylee | F | 33 | bbbbbbbbbb |
| 197 | hanyuliu | F | 25 | aaaaaaaaaa |
| 198 | andkylee | F | 33 | bbbbbbbbbb |
| 199 | hanyuliu | F | 25 | aaaaaaaaaa |
| 200 | andkylee | F | 33 | bbbbbbbbbb |
| 201 | hanyuliu | F | 25 | aaaaaaaaaa |
| 202 | andkylee | F | 33 | bbbbbbbbbb |
| 203 | hanyuliu | F | 25 | aaaaaaaaaa |
| 204 | andkylee | F | 33 | bbbbbbbbbb |
| 205 | hanyuliu | F | 25 | aaaaaaaaaa |
| 206 | andkylee | F | 33 | bbbbbbbbbb |
| 207 | hanyuliu | F | 25 | aaaaaaaaaa |
| 208 | andkylee | F | 33 | bbbbbbbbbb |
| 209 | hanyuliu | F | 25 | aaaaaaaaaa |
| 210 | andkylee | F | 33 | bbbbbbbbbb |
| 211 | hanyuliu | F | 25 | aaaaaaaaaa |
| 212 | andkylee | F | 33 | bbbbbbbbbb |
| 213 | hanyuliu | F | 25 | aaaaaaaaaa |
| 214 | andkylee | F | 33 | bbbbbbbbbb |
| 215 | hanyuliu | F | 25 | aaaaaaaaaa |
| 216 | andkylee | F | 33 | bbbbbbbbbb |
| 217 | hanyuliu | F | 25 | aaaaaaaaaa |
| 218 | andkylee | F | 33 | bbbbbbbbbb |
| 219 | hanyuliu | F | 25 | aaaaaaaaaa |
| 220 | andkylee | F | 33 | bbbbbbbbbb |
| 221 | hanyuliu | F | 25 | aaaaaaaaaa |
| 222 | andkylee | F | 33 | bbbbbbbbbb |
| 223 | hanyuliu | F | 25 | aaaaaaaaaa |
| 224 | andkylee | F | 33 | bbbbbbbbbb |
| 225 | hanyuliu | F | 25 | aaaaaaaaaa |
| 226 | andkylee | F | 33 | bbbbbbbbbb |
| 227 | hanyuliu | F | 25 | aaaaaaaaaa |
| 228 | andkylee | F | 33 | bbbbbbbbbb |
| 229 | hanyuliu | F | 25 | aaaaaaaaaa |
| 230 | andkylee | F | 33 | bbbbbbbbbb |
| 231 | hanyuliu | F | 25 | aaaaaaaaaa |
| 232 | andkylee | F | 33 | bbbbbbbbbb |
| 233 | hanyuliu | F | 25 | aaaaaaaaaa |
| 234 | andkylee | F | 33 | bbbbbbbbbb |
| 235 | hanyuliu | F | 25 | aaaaaaaaaa |
| 236 | andkylee | F | 33 | bbbbbbbbbb |
| 237 | hanyuliu | F | 25 | aaaaaaaaaa |
| 238 | andkylee | F | 33 | bbbbbbbbbb |
| 239 | hanyuliu | F | 25 | aaaaaaaaaa |
| 240 | andkylee | F | 33 | bbbbbbbbbb |
| 241 | hanyuliu | F | 25 | aaaaaaaaaa |
| 242 | andkylee | F | 33 | bbbbbbbbbb |
| 243 | hanyuliu | F | 25 | aaaaaaaaaa |
| 244 | andkylee | F | 33 | bbbbbbbbbb |
| 245 | hanyuliu | F | 25 | aaaaaaaaaa |
| 246 | andkylee | F | 33 | bbbbbbbbbb |
| 247 | hanyuliu | F | 25 | aaaaaaaaaa |
| 248 | andkylee | F | 33 | bbbbbbbbbb |
| 249 | hanyuliu | F | 25 | aaaaaaaaaa |
| 250 | andkylee | F | 33 | bbbbbbbbbb |
| 251 | hanyuliu | F | 25 | aaaaaaaaaa |
| 252 | andkylee | F | 33 | bbbbbbbbbb |
| 253 | hanyuliu | F | 25 | aaaaaaaaaa |
| 254 | andkylee | F | 33 | bbbbbbbbbb |
| 255 | hanyuliu | F | 25 | aaaaaaaaaa |
| 256 | andkylee | F | 33 | bbbbbbbbbb |
| 257 | hanyuliu | F | 25 | aaaaaaaaaa |
| 258 | andkylee | F | 33 | bbbbbbbbbb |
| 259 | hanyuliu | F | 25 | aaaaaaaaaa |
| 260 | andkylee | F | 33 | bbbbbbbbbb |
| 261 | hanyuliu | F | 25 | aaaaaaaaaa |
| 262 | andkylee | F | 33 | bbbbbbbbbb |
| 263 | hanyuliu | F | 25 | aaaaaaaaaa |
| 264 | andkylee | F | 33 | bbbbbbbbbb |
| 265 | hanyuliu | F | 25 | aaaaaaaaaa |
| 266 | andkylee | F | 33 | bbbbbbbbbb |
| 267 | hanyuliu | F | 25 | aaaaaaaaaa |
| 268 | andkylee | F | 33 | bbbbbbbbbb |
| 269 | hanyuliu | F | 25 | aaaaaaaaaa |
| 270 | andkylee | F | 33 | bbbbbbbbbb |
| 271 | hanyuliu | F | 25 | aaaaaaaaaa |
| 272 | andkylee | F | 33 | bbbbbbbbbb |
| 273 | hanyuliu | F | 25 | aaaaaaaaaa |
| 274 | andkylee | F | 33 | bbbbbbbbbb |
| 275 | hanyuliu | F | 25 | aaaaaaaaaa |
| 276 | andkylee | F | 33 | bbbbbbbbbb |
| 277 | hanyuliu | F | 25 | aaaaaaaaaa |
| 278 | andkylee | F | 33 | bbbbbbbbbb |
| 279 | hanyuliu | F | 25 | aaaaaaaaaa |
| 280 | andkylee | F | 33 | bbbbbbbbbb |
| 281 | hanyuliu | F | 25 | aaaaaaaaaa |
| 282 | andkylee | F | 33 | bbbbbbbbbb |
| 283 | hanyuliu | F | 25 | aaaaaaaaaa |
| 284 | andkylee | F | 33 | bbbbbbbbbb |
| 285 | hanyuliu | F | 25 | aaaaaaaaaa |
| 286 | andkylee | F | 33 | bbbbbbbbbb |
| 287 | hanyuliu | F | 25 | aaaaaaaaaa |
| 288 | andkylee | F | 33 | bbbbbbbbbb |
| 289 | hanyuliu | F | 25 | aaaaaaaaaa |
| 290 | andkylee | F | 33 | bbbbbbbbbb |
| 291 | hanyuliu | F | 25 | aaaaaaaaaa |
| 292 | andkylee | F | 33 | bbbbbbbbbb |
| 293 | hanyuliu | F | 25 | aaaaaaaaaa |
| 294 | andkylee | F | 33 | bbbbbbbbbb |
| 295 | hanyuliu | F | 25 | aaaaaaaaaa |
| 296 | andkylee | F | 33 | bbbbbbbbbb |
| 297 | hanyuliu | F | 25 | aaaaaaaaaa |
| 298 | andkylee | F | 33 | bbbbbbbbbb |
| 299 | hanyuliu | F | 25 | aaaaaaaaaa |
| 300 | andkylee | F | 33 | bbbbbbbbbb |
+-----+----------+-----+------+------------+
201 rows in set (0.00 sec)
mysql>
再展示一个带where条件的语句的limit使用情况。
返回name为'andkylee'的所有记录的第100至300行数据。
select *from andkylee where name='andkylee' LimiT 99,201;
结果为:
mysql> select *from andkylee where name='andkylee' LimiT 99,201;
+-----+----------+-----+------+------------+
| id | name | sex | age | note |
+-----+----------+-----+------+------------+
| 200 | andkylee | F | 33 | bbbbbbbbbb |
| 202 | andkylee | F | 33 | bbbbbbbbbb |
| 204 | andkylee | F | 33 | bbbbbbbbbb |
| 206 | andkylee | F | 33 | bbbbbbbbbb |
| 208 | andkylee | F | 33 | bbbbbbbbbb |
| 210 | andkylee | F | 33 | bbbbbbbbbb |
| 212 | andkylee | F | 33 | bbbbbbbbbb |
| 214 | andkylee | F | 33 | bbbbbbbbbb |
| 216 | andkylee | F | 33 | bbbbbbbbbb |
| 218 | andkylee | F | 33 | bbbbbbbbbb |
| 220 | andkylee | F | 33 | bbbbbbbbbb |
| 222 | andkylee | F | 33 | bbbbbbbbbb |
| 224 | andkylee | F | 33 | bbbbbbbbbb |
| 226 | andkylee | F | 33 | bbbbbbbbbb |
| 228 | andkylee | F | 33 | bbbbbbbbbb |
| 230 | andkylee | F | 33 | bbbbbbbbbb |
| 232 | andkylee | F | 33 | bbbbbbbbbb |
| 234 | andkylee | F | 33 | bbbbbbbbbb |
| 236 | andkylee | F | 33 | bbbbbbbbbb |
| 238 | andkylee | F | 33 | bbbbbbbbbb |
| 240 | andkylee | F | 33 | bbbbbbbbbb |
| 242 | andkylee | F | 33 | bbbbbbbbbb |
| 244 | andkylee | F | 33 | bbbbbbbbbb |
| 246 | andkylee | F | 33 | bbbbbbbbbb |
| 248 | andkylee | F | 33 | bbbbbbbbbb |
| 250 | andkylee | F | 33 | bbbbbbbbbb |
| 252 | andkylee | F | 33 | bbbbbbbbbb |
| 254 | andkylee | F | 33 | bbbbbbbbbb |
| 256 | andkylee | F | 33 | bbbbbbbbbb |
| 258 | andkylee | F | 33 | bbbbbbbbbb |
| 260 | andkylee | F | 33 | bbbbbbbbbb |
| 262 | andkylee | F | 33 | bbbbbbbbbb |
| 264 | andkylee | F | 33 | bbbbbbbbbb |
| 266 | andkylee | F | 33 | bbbbbbbbbb |
| 268 | andkylee | F | 33 | bbbbbbbbbb |
| 270 | andkylee | F | 33 | bbbbbbbbbb |
| 272 | andkylee | F | 33 | bbbbbbbbbb |
| 274 | andkylee | F | 33 | bbbbbbbbbb |
| 276 | andkylee | F | 33 | bbbbbbbbbb |
| 278 | andkylee | F | 33 | bbbbbbbbbb |
| 280 | andkylee | F | 33 | bbbbbbbbbb |
| 282 | andkylee | F | 33 | bbbbbbbbbb |
| 284 | andkylee | F | 33 | bbbbbbbbbb |
| 286 | andkylee | F | 33 | bbbbbbbbbb |
| 288 | andkylee | F | 33 | bbbbbbbbbb |
| 290 | andkylee | F | 33 | bbbbbbbbbb |
| 292 | andkylee | F | 33 | bbbbbbbbbb |
| 294 | andkylee | F | 33 | bbbbbbbbbb |
| 296 | andkylee | F | 33 | bbbbbbbbbb |
| 298 | andkylee | F | 33 | bbbbbbbbbb |
| 300 | andkylee | F | 33 | bbbbbbbbbb |
| 302 | andkylee | F | 33 | bbbbbbbbbb |
| 304 | andkylee | F | 33 | bbbbbbbbbb |
| 306 | andkylee | F | 33 | bbbbbbbbbb |
| 308 | andkylee | F | 33 | bbbbbbbbbb |
| 310 | andkylee | F | 33 | bbbbbbbbbb |
| 312 | andkylee | F | 33 | bbbbbbbbbb |
| 314 | andkylee | F | 33 | bbbbbbbbbb |
| 316 | andkylee | F | 33 | bbbbbbbbbb |
| 318 | andkylee | F | 33 | bbbbbbbbbb |
| 320 | andkylee | F | 33 | bbbbbbbbbb |
| 322 | andkylee | F | 33 | bbbbbbbbbb |
| 324 | andkylee | F | 33 | bbbbbbbbbb |
| 326 | andkylee | F | 33 | bbbbbbbbbb |
| 328 | andkylee | F | 33 | bbbbbbbbbb |
| 330 | andkylee | F | 33 | bbbbbbbbbb |
| 332 | andkylee | F | 33 | bbbbbbbbbb |
| 334 | andkylee | F | 33 | bbbbbbbbbb |
| 336 | andkylee | F | 33 | bbbbbbbbbb |
| 338 | andkylee | F | 33 | bbbbbbbbbb |
| 340 | andkylee | F | 33 | bbbbbbbbbb |
| 342 | andkylee | F | 33 | bbbbbbbbbb |
| 344 | andkylee | F | 33 | bbbbbbbbbb |
| 346 | andkylee | F | 33 | bbbbbbbbbb |
| 348 | andkylee | F | 33 | bbbbbbbbbb |
| 350 | andkylee | F | 33 | bbbbbbbbbb |
| 352 | andkylee | F | 33 | bbbbbbbbbb |
| 354 | andkylee | F | 33 | bbbbbbbbbb |
| 356 | andkylee | F | 33 | bbbbbbbbbb |
| 358 | andkylee | F | 33 | bbbbbbbbbb |
| 360 | andkylee | F | 33 | bbbbbbbbbb |
| 362 | andkylee | F | 33 | bbbbbbbbbb |
| 364 | andkylee | F | 33 | bbbbbbbbbb |
| 366 | andkylee | F | 33 | bbbbbbbbbb |
| 368 | andkylee | F | 33 | bbbbbbbbbb |
| 370 | andkylee | F | 33 | bbbbbbbbbb |
| 372 | andkylee | F | 33 | bbbbbbbbbb |
| 374 | andkylee | F | 33 | bbbbbbbbbb |
| 376 | andkylee | F | 33 | bbbbbbbbbb |
| 378 | andkylee | F | 33 | bbbbbbbbbb |
| 380 | andkylee | F | 33 | bbbbbbbbbb |
| 382 | andkylee | F | 33 | bbbbbbbbbb |
| 384 | andkylee | F | 33 | bbbbbbbbbb |
| 386 | andkylee | F | 33 | bbbbbbbbbb |
| 388 | andkylee | F | 33 | bbbbbbbbbb |
| 390 | andkylee | F | 33 | bbbbbbbbbb |
| 392 | andkylee | F | 33 | bbbbbbbbbb |
| 394 | andkylee | F | 33 | bbbbbbbbbb |
| 396 | andkylee | F | 33 | bbbbbbbbbb |
| 398 | andkylee | F | 33 | bbbbbbbbbb |
| 400 | andkylee | F | 33 | bbbbbbbbbb |
| 402 | andkylee | F | 33 | bbbbbbbbbb |
| 404 | andkylee | F | 33 | bbbbbbbbbb |
| 406 | andkylee | F | 33 | bbbbbbbbbb |
| 408 | andkylee | F | 33 | bbbbbbbbbb |
| 410 | andkylee | F | 33 | bbbbbbbbbb |
| 412 | andkylee | F | 33 | bbbbbbbbbb |
| 414 | andkylee | F | 33 | bbbbbbbbbb |
| 416 | andkylee | F | 33 | bbbbbbbbbb |
| 418 | andkylee | F | 33 | bbbbbbbbbb |
| 420 | andkylee | F | 33 | bbbbbbbbbb |
| 422 | andkylee | F | 33 | bbbbbbbbbb |
| 424 | andkylee | F | 33 | bbbbbbbbbb |
| 426 | andkylee | F | 33 | bbbbbbbbbb |
| 428 | andkylee | F | 33 | bbbbbbbbbb |
| 430 | andkylee | F | 33 | bbbbbbbbbb |
| 432 | andkylee | F | 33 | bbbbbbbbbb |
| 434 | andkylee | F | 33 | bbbbbbbbbb |
| 436 | andkylee | F | 33 | bbbbbbbbbb |
| 438 | andkylee | F | 33 | bbbbbbbbbb |
| 440 | andkylee | F | 33 | bbbbbbbbbb |
| 442 | andkylee | F | 33 | bbbbbbbbbb |
| 444 | andkylee | F | 33 | bbbbbbbbbb |
| 446 | andkylee | F | 33 | bbbbbbbbbb |
| 448 | andkylee | F | 33 | bbbbbbbbbb |
| 450 | andkylee | F | 33 | bbbbbbbbbb |
| 452 | andkylee | F | 33 | bbbbbbbbbb |
| 454 | andkylee | F | 33 | bbbbbbbbbb |
| 456 | andkylee | F | 33 | bbbbbbbbbb |
| 458 | andkylee | F | 33 | bbbbbbbbbb |
| 460 | andkylee | F | 33 | bbbbbbbbbb |
| 462 | andkylee | F | 33 | bbbbbbbbbb |
| 464 | andkylee | F | 33 | bbbbbbbbbb |
| 466 | andkylee | F | 33 | bbbbbbbbbb |
| 468 | andkylee | F | 33 | bbbbbbbbbb |
| 470 | andkylee | F | 33 | bbbbbbbbbb |
| 472 | andkylee | F | 33 | bbbbbbbbbb |
| 474 | andkylee | F | 33 | bbbbbbbbbb |
| 476 | andkylee | F | 33 | bbbbbbbbbb |
| 478 | andkylee | F | 33 | bbbbbbbbbb |
| 480 | andkylee | F | 33 | bbbbbbbbbb |
| 482 | andkylee | F | 33 | bbbbbbbbbb |
| 484 | andkylee | F | 33 | bbbbbbbbbb |
| 486 | andkylee | F | 33 | bbbbbbbbbb |
| 488 | andkylee | F | 33 | bbbbbbbbbb |
| 490 | andkylee | F | 33 | bbbbbbbbbb |
| 492 | andkylee | F | 33 | bbbbbbbbbb |
| 494 | andkylee | F | 33 | bbbbbbbbbb |
| 496 | andkylee | F | 33 | bbbbbbbbbb |
| 498 | andkylee | F | 33 | bbbbbbbbbb |
| 500 | andkylee | F | 33 | bbbbbbbbbb |
| 502 | andkylee | F | 33 | bbbbbbbbbb |
| 504 | andkylee | F | 33 | bbbbbbbbbb |
| 506 | andkylee | F | 33 | bbbbbbbbbb |
| 508 | andkylee | F | 33 | bbbbbbbbbb |
| 510 | andkylee | F | 33 | bbbbbbbbbb |
| 512 | andkylee | F | 33 | bbbbbbbbbb |
| 514 | andkylee | F | 33 | bbbbbbbbbb |
| 516 | andkylee | F | 33 | bbbbbbbbbb |
| 518 | andkylee | F | 33 | bbbbbbbbbb |
| 520 | andkylee | F | 33 | bbbbbbbbbb |
| 522 | andkylee | F | 33 | bbbbbbbbbb |
| 524 | andkylee | F | 33 | bbbbbbbbbb |
| 526 | andkylee | F | 33 | bbbbbbbbbb |
| 528 | andkylee | F | 33 | bbbbbbbbbb |
| 530 | andkylee | F | 33 | bbbbbbbbbb |
| 532 | andkylee | F | 33 | bbbbbbbbbb |
| 534 | andkylee | F | 33 | bbbbbbbbbb |
| 536 | andkylee | F | 33 | bbbbbbbbbb |
| 538 | andkylee | F | 33 | bbbbbbbbbb |
| 540 | andkylee | F | 33 | bbbbbbbbbb |
| 542 | andkylee | F | 33 | bbbbbbbbbb |
| 544 | andkylee | F | 33 | bbbbbbbbbb |
| 546 | andkylee | F | 33 | bbbbbbbbbb |
| 548 | andkylee | F | 33 | bbbbbbbbbb |
| 550 | andkylee | F | 33 | bbbbbbbbbb |
| 552 | andkylee | F | 33 | bbbbbbbbbb |
| 554 | andkylee | F | 33 | bbbbbbbbbb |
| 556 | andkylee | F | 33 | bbbbbbbbbb |
| 558 | andkylee | F | 33 | bbbbbbbbbb |
| 560 | andkylee | F | 33 | bbbbbbbbbb |
| 562 | andkylee | F | 33 | bbbbbbbbbb |
| 564 | andkylee | F | 33 | bbbbbbbbbb |
| 566 | andkylee | F | 33 | bbbbbbbbbb |
| 568 | andkylee | F | 33 | bbbbbbbbbb |
| 570 | andkylee | F | 33 | bbbbbbbbbb |
| 572 | andkylee | F | 33 | bbbbbbbbbb |
| 574 | andkylee | F | 33 | bbbbbbbbbb |
| 576 | andkylee | F | 33 | bbbbbbbbbb |
| 578 | andkylee | F | 33 | bbbbbbbbbb |
| 580 | andkylee | F | 33 | bbbbbbbbbb |
| 582 | andkylee | F | 33 | bbbbbbbbbb |
| 584 | andkylee | F | 33 | bbbbbbbbbb |
| 586 | andkylee | F | 33 | bbbbbbbbbb |
| 588 | andkylee | F | 33 | bbbbbbbbbb |
| 590 | andkylee | F | 33 | bbbbbbbbbb |
| 592 | andkylee | F | 33 | bbbbbbbbbb |
| 594 | andkylee | F | 33 | bbbbbbbbbb |
| 596 | andkylee | F | 33 | bbbbbbbbbb |
| 598 | andkylee | F | 33 | bbbbbbbbbb |
| 600 | andkylee | F | 33 | bbbbbbbbbb |
+-----+----------+-----+------+------------+
201 rows in set (0.09 sec)
mysql>
4. 功能完善。
通过第3步骤中的两个结果集进行对比,我们可以发现,MySQL中的limit关键字类似于一个伪列的功能。比oracle中的rownum要强大,在oracle中要通过一次rownum再加一次虚拟列才能实现类似MySQL中的limit功能。因此limit功能存在优势的地方在于:不产生虚拟列。也就是说你不需要花费额外的功夫来处理列名列表了。最简单的就是直接用星号*,开发人员在编写存错过程的时候比较省事了。
最后,个人感觉:通过比较mssqlserver,oracle,sybase中的分页是实现方式,我感觉MySQL的limit是最简单最方便的。
————————————————————————————————-
—- 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
—- 转载务必注明原始出处 : http://www.dbainfo.net
—- 关键字:MySQL 分页 limit
————————————————————————————————-