Maison > Article > base de données > 三种常用数据库(Oracle、MySQL、SQLServer)的分页之MySQL分页
环境 MySQL 5.1 命令行工具 问题 MySQL 分页 解决 --创建测试表create table test(id int(11) primary key auto_increment,name varchar(20) not null);--插入数据mysql insert into test(name) values('test1');Query OK, 1 row affected (0.16 sec)mysql i
MySQL 5.1 + 命令行工具
MySQL分页
--创建测试表 create table test ( id int(11) primary key auto_increment, name varchar(20) not null ); --插入数据 mysql> insert into test(name) values('test1'); Query OK, 1 row affected (0.16 sec) mysql> insert into test(name) values('test2'); Query OK, 1 row affected (0.01 sec) mysql> insert into test(name) values('test3'); Query OK, 1 row affected (0.00 sec) mysql> insert into test(name) values('test4'); Query OK, 1 row affected (0.00 sec) mysql> insert into test(name) values('test5'); Query OK, 1 row affected (0.03 sec) mysql> insert into test(name) values('test6'); Query OK, 1 row affected (0.01 sec) mysql> insert into test(name) values('test7'); Query OK, 1 row affected (0.06 sec) mysql> insert into test(name) values('test8'); Query OK, 1 row affected (0.00 sec) mysql> insert into test(name) values('test9'); Query OK, 1 row affected (0.01 sec) mysql> insert into test(name) values('test10'); Query OK, 1 row affected (0.01 sec) --执行分页 mysql> select id,name from test limit 0,10; +----+--------+ | id | name | +----+--------+ | 1 | test1 | | 2 | test2 | | 3 | test3 | | 4 | test4 | | 5 | test5 | | 6 | test6 | | 7 | test7 | | 8 | test8 | | 9 | test9 | | 10 | test10 | +----+--------+ 10 rows in set (0.00 sec)
快速插入数据:
insert into test(name) select name from test;
详情参考此文:在MySQL中快速复制数据表方法汇总
http://blog.csdn.net/btbdylq/article/details/6827981
select id,name from test limit参数1,参数2;
参数1,从第几条开始
参数2,返回多少条数据
JavaWeb中实现分页算法
select * from tableName limit (pageNow-1)*pagesize,pagesize
pageNow:当前第几页
pageSize:每页显示的记录数
http://zhidao.baidu.com/question/248872252.html
http://zhidao.baidu.com/question/159608774.html