﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-liangcmwn-文章分类-mysql</title><link>http://www.blogjava.net/liangcmwn/category/49243.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 24 Aug 2011 07:27:16 GMT</lastBuildDate><pubDate>Wed, 24 Aug 2011 07:27:16 GMT</pubDate><ttl>60</ttl><item><title>MySQL同步故障：" Slave_SQL_Running:No" 两种解决办法  </title><link>http://www.blogjava.net/liangcmwn/articles/356604.html</link><dc:creator>liangcmwn</dc:creator><author>liangcmwn</author><pubDate>Tue, 16 Aug 2011 01:31:00 GMT</pubDate><guid>http://www.blogjava.net/liangcmwn/articles/356604.html</guid><wfw:comment>http://www.blogjava.net/liangcmwn/comments/356604.html</wfw:comment><comments>http://www.blogjava.net/liangcmwn/articles/356604.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liangcmwn/comments/commentRss/356604.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liangcmwn/services/trackbacks/356604.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; "><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">进入slave服务器，运行：</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mysql&gt; show slave status\G</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .......<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Relay_Log_File: localhost-relay-bin.000535<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Relay_Log_Pos: 21795072<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Relay_Master_Log_File: localhost-bin.000094<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#66ff00" style="line-height: 22px; ">&nbsp;&nbsp;</font><font color="#00cc00" style="line-height: 22px; "><u style="line-height: 22px; ">Slave_IO_Running: Yes</u></font><br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff6600" style="line-height: 22px; "><u style="line-height: 22px; ">Slave_SQL_Running:&nbsp;No</u></font><br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Replicate_Do_DB:&nbsp;<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Replicate_Ignore_DB:&nbsp;<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;......</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strong style="line-height: 22px; ">解决办法一、</strong></p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Slave_SQL_Running: No<br style="line-height: 22px; " />1.程序可能在slave上进行了写操作</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2.也可能是slave机器重起后，事务回滚造成的.<br style="line-height: 22px; " /><br style="line-height: 22px; " />一般是事务回滚造成的：<br style="line-height: 22px; " />解决办法：<br style="line-height: 22px; " />mysql&gt; slave stop;<br style="line-height: 22px; " />mysql&gt; set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;<br style="line-height: 22px; " />mysql&gt; slave start;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-weight: bold; ">解决办法二、</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">首先停掉Slave服务：slave stop<br style="line-height: 22px; " />到主服务器上查看主机状态：<br style="line-height: 22px; " />记录File和Position对应的值</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">进入master</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mysql&gt; show master status;<br style="line-height: 22px; " />+----------------------+----------+--------------+------------------+<br style="line-height: 22px; " />| File&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Position | Binlog_Do_DB | Binlog_Ignore_DB |<br style="line-height: 22px; " />+----------------------+----------+--------------+------------------+<br style="line-height: 22px; " />| localhost-bin.000094 | 33622483 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;<br style="line-height: 22px; " />+----------------------+----------+--------------+------------------+<br style="line-height: 22px; " />1 row in set (0.00 sec)</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">然后到slave服务器上执行手动同步：<br style="line-height: 22px; " /><code style="line-height: 22px; "><br style="line-height: 22px; " />mysql&gt; change master to&nbsp;<br style="line-height: 22px; " />&gt; master_host='master_ip',<br style="line-height: 22px; " />&gt; master_user='user',&nbsp;<br style="line-height: 22px; " />&gt; master_password='pwd',&nbsp;<br style="line-height: 22px; " />&gt; master_port=3306,&nbsp;<br style="line-height: 22px; " />&gt; master_log_file=<font face="Arial" style="line-height: 22px; ">localhost-bin.000094</font>',&nbsp;<br style="line-height: 22px; " />&gt; master_log_pos=<font face="Arial" style="line-height: 22px; ">33622483&nbsp;</font>;<br style="line-height: 22px; " />1 row in set (0.00 sec)<br style="line-height: 22px; " />mysql&gt; slave start;<br style="line-height: 22px; " />1 row in set (0.00 sec)</code></p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mysql&gt; show slave status\G<br style="line-height: 22px; " />*************************** 1. row ***************************<br style="line-height: 22px; " />........<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Master_Log_File: localhost-bin.000094<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Read_Master_Log_Pos: 33768775<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Relay_Log_File: localhost-relay-bin.000537<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Relay_Log_Pos: 1094034<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Relay_Master_Log_File: localhost-bin.000094<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00cc00" style="line-height: 22px; ">&nbsp;Slave_IO_Running: Yes<br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Slave_SQL_Running: Yes</font><br style="line-height: 22px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Replicate_Do_DB:</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">手动同步需要停止master的写操作！&nbsp;</p></span><img src ="http://www.blogjava.net/liangcmwn/aggbug/356604.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liangcmwn/" target="_blank">liangcmwn</a> 2011-08-16 09:31 <a href="http://www.blogjava.net/liangcmwn/articles/356604.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL InnoDB存储引擎的事务隔离级别</title><link>http://www.blogjava.net/liangcmwn/articles/356601.html</link><dc:creator>liangcmwn</dc:creator><author>liangcmwn</author><pubDate>Tue, 16 Aug 2011 01:15:00 GMT</pubDate><guid>http://www.blogjava.net/liangcmwn/articles/356601.html</guid><wfw:comment>http://www.blogjava.net/liangcmwn/comments/356601.html</wfw:comment><comments>http://www.blogjava.net/liangcmwn/articles/356601.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liangcmwn/comments/commentRss/356601.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liangcmwn/services/trackbacks/356601.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff; "><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">我们知道，在关系<a href="http://space.itpub.net/8562502/viewspace-232238" target="_self" style="word-break: break-all; text-decoration: underline; color: #000066; line-height: normal !important; "><u style="word-break: break-all; line-height: normal !important; "><strong style="word-break: break-all; line-height: normal !important; ">数据库</strong></u></a>标准中有四个事务隔离级别：</p><ul style="word-break: break-all; line-height: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 3em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="word-break: break-all; line-height: normal; ">未提交读(Read Uncommitted)：允许脏读，也就是可能读取到其他会话中未提交事务修改的数据</li><li style="word-break: break-all; line-height: normal; ">提交读(Read Committed)：只能读取到已经提交的数据。Oracle等多数数据库默认都是该级别</li><li style="word-break: break-all; line-height: normal; ">可重复读(Repeated Read)：可重复读。在同一个事务内的查询都是事务开始时刻一致的，<strong style="word-break: break-all; line-height: normal; ">InnoDB默认级别</strong>。在<a href="http://space.itpub.net/8562502/viewspace-232238" target="_self" style="word-break: break-all; text-decoration: underline; color: #000066; line-height: normal; padding-left: 0px; background-image: none; "><u style="word-break: break-all; line-height: normal; "><strong style="word-break: break-all; line-height: normal; ">SQL</strong></u></a>标准中，该隔离级别消除了不可重复读，但是还存在幻象读</li><li style="word-break: break-all; line-height: normal; ">串行读(Serializable)：完全串行化的读，每次读都需要获得表级共享锁，读写相互都会阻塞</li></ul><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">查看InnoDB系统级别的事务隔离级别：</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; SELECT @@global.tx_isolation;<br style="word-break: break-all; line-height: normal !important; " />+-----------------------+<br style="word-break: break-all; line-height: normal !important; " />| @@global.tx_isolation |<br style="word-break: break-all; line-height: normal !important; " />+-----------------------+<br style="word-break: break-all; line-height: normal !important; " />| REPEATABLE-READ&nbsp; &nbsp; &nbsp; &nbsp;|<br style="word-break: break-all; line-height: normal !important; " />+-----------------------+<br style="word-break: break-all; line-height: normal !important; " />1 row in set (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">查看InnoDB会话级别的事务隔离级别：</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; SELECT @@tx_isolation;<br style="word-break: break-all; line-height: normal !important; " />+-----------------+<br style="word-break: break-all; line-height: normal !important; " />| @@tx_isolation&nbsp; |<br style="word-break: break-all; line-height: normal !important; " />+-----------------+<br style="word-break: break-all; line-height: normal !important; " />| REPEATABLE-READ |<br style="word-break: break-all; line-height: normal !important; " />+-----------------+<br style="word-break: break-all; line-height: normal !important; " />1 row in set (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">修改事务隔离级别：</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; set global transaction isolation level read committed;<br style="word-break: break-all; line-height: normal !important; " />Query OK, 0 rows affected (0.00 sec)<br style="word-break: break-all; line-height: normal !important; " /><br style="word-break: break-all; line-height: normal !important; " />mysql&gt; set session transaction isolation level read committed;<br style="word-break: break-all; line-height: normal !important; " />Query OK, 0 rows affected (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><span id="more-91" style="word-break: break-all; line-height: normal !important; "></span></p><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">InnoDB的可重复读隔离级别和其他数据库的可重复读是有区别的，不会造成幻象读（phantom read），所谓幻象读，就是同一个事务内，多次select，可以读取到其他session insert并已经commit的数据。下面是一个小的测试，证明InnoDB的可重复读隔离级别不会造成幻象读。测试涉及两个session，分别为session 1和session 2，隔离级别都是repeateable read，关闭autocommit</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; select @@tx_isolation;<br style="word-break: break-all; line-height: normal !important; " />+-----------------+<br style="word-break: break-all; line-height: normal !important; " />| @@tx_isolation&nbsp; |<br style="word-break: break-all; line-height: normal !important; " />+-----------------+<br style="word-break: break-all; line-height: normal !important; " />| REPEATABLE-READ |<br style="word-break: break-all; line-height: normal !important; " />+-----------------+<br style="word-break: break-all; line-height: normal !important; " />1 row in set (0.00 sec)<br style="word-break: break-all; line-height: normal !important; " /><br style="word-break: break-all; line-height: normal !important; " />mysql&gt; set autocommit=off;<br style="word-break: break-all; line-height: normal !important; " />Query OK, 0 rows affected (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">session 1 创建表并插入测试数据</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; create table test(i int) engine=innodb;<br style="word-break: break-all; line-height: normal !important; " />Query OK, 0 rows affected (0.00 sec)<br style="word-break: break-all; line-height: normal !important; " /><br style="word-break: break-all; line-height: normal !important; " />mysql&gt; insert into test values(1);<br style="word-break: break-all; line-height: normal !important; " />Query OK, 1 row affected (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">session 2 查询，没有数据，正常，session1没有提交，不允许脏读</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; select * from test;<br style="word-break: break-all; line-height: normal !important; " />Empty set (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">session 1 提交事务</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; commit;<br style="word-break: break-all; line-height: normal !important; " />Query OK, 0 rows affected (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">session 2 查询，还是没有数据，没有产生幻象读</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; select * from test;<br style="word-break: break-all; line-height: normal !important; " />Empty set (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">以上试验版本：</p><div class="hl-surround" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><div class="hl-main" style="word-break: break-all; line-height: normal !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">mysql&gt; select version();<br style="word-break: break-all; line-height: normal !important; " />+-------------------------+<br style="word-break: break-all; line-height: normal !important; " />| version()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br style="word-break: break-all; line-height: normal !important; " />+-------------------------+<br style="word-break: break-all; line-height: normal !important; " />| 5.0.37-community-nt-log |<br style="word-break: break-all; line-height: normal !important; " />+-------------------------+<br style="word-break: break-all; line-height: normal !important; " />1 row in set (0.00 sec)</div></div><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">--EOF--</p><div id="copyright" style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">作者：<a title="江枫 发布" href="http://rdc.taobao.com/blog/dba/html/author/jiangfeng/" style="word-break: break-all; text-decoration: underline; color: #000066; line-height: normal !important; ">江枫</a>| 【转载时请务必以超链接形式标明文章原始出处和作者信息及本声明】<br style="word-break: break-all; line-height: normal !important; " />地址：<a title="traceback" href="http://rdc.taobao.com/blog/dba/html/91_mysql_innodb_transaction_isolation_level.html" rel="trackback" style="word-break: break-all; text-decoration: underline; color: #000066; line-height: normal !important; ">http://rdc.taobao.com/blog/dba/html/91_mysql_innodb_transaction_isolation_level.html</a></div></span><img src ="http://www.blogjava.net/liangcmwn/aggbug/356601.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liangcmwn/" target="_blank">liangcmwn</a> 2011-08-16 09:15 <a href="http://www.blogjava.net/liangcmwn/articles/356601.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Mysql常用操作</title><link>http://www.blogjava.net/liangcmwn/articles/356576.html</link><dc:creator>liangcmwn</dc:creator><author>liangcmwn</author><pubDate>Mon, 15 Aug 2011 08:50:00 GMT</pubDate><guid>http://www.blogjava.net/liangcmwn/articles/356576.html</guid><wfw:comment>http://www.blogjava.net/liangcmwn/comments/356576.html</wfw:comment><comments>http://www.blogjava.net/liangcmwn/articles/356576.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liangcmwn/comments/commentRss/356576.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liangcmwn/services/trackbacks/356576.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #444444; font-family: 宋体; line-height: 28px; background-color: #ffffff; "><p style="outline-style: none; outline-width: initial; outline-color: initial; line-height: 21px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><strong style="outline-style: none; outline-width: initial; outline-color: initial; ">查看MySQL的当前存储引擎</strong></p><p style="outline-style: none; outline-width: initial; outline-color: initial; line-height: 21px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">一般情况下，mysql会默认提供多种存储引擎,你可以通过下面的查看:</p><p style="outline-style: none; outline-width: initial; outline-color: initial; line-height: 21px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">看你的mysql现在已提供什么存储引擎:<br style="outline-style: none; outline-width: initial; outline-color: initial; " />mysql&gt; show engines;</p><p style="outline-style: none; outline-width: initial; outline-color: initial; line-height: 21px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">看你的mysql当前默认的存储引擎:<br style="outline-style: none; outline-width: initial; outline-color: initial; " />mysql&gt; show variables like '%storage_engine%';</p><p style="outline-style: none; outline-width: initial; outline-color: initial; line-height: 21px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">你要看某个表用了什么引擎(在显示结果里参数engine后面的就表示该表当前用的存储引擎):<br style="outline-style: none; outline-width: initial; outline-color: initial; " />mysql&gt; show create table 表名;<br /><br /></p></span><span class="Apple-style-span" style="color: #010066; font-family: Arial, Helvetica, sans-serif, 宋体; font-size: 12px; background-color: #234489; "><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><a href="http://space.itpub.net/8102208/viewspace-605548" target="_self" style="word-break: break-all; text-decoration: underline; color: #070648; line-height: normal !important; "><u style="word-break: break-all; line-height: normal !important; "><strong style="word-break: break-all; line-height: normal !important; ">MySQL</strong></u></a>&nbsp;乱码的根源是的 MySQL 字符集设置不当的问题，本文汇总了有关查看 MySQL 字符集的命令。包括查看 MySQL&nbsp;<a href="http://space.itpub.net/8102208/viewspace-605548" target="_self" style="word-break: break-all; text-decoration: underline; color: #070648; line-height: normal !important; "><u style="word-break: break-all; line-height: normal !important; "><strong style="word-break: break-all; line-height: normal !important; ">数据库</strong></u></a>服务器字符集、查看 MySQL 数据库字符集，以及数据表和字段的字符集、当前<a href="http://space.itpub.net/8102208/viewspace-605548" target="_self" style="word-break: break-all; text-decoration: underline; color: #070648; line-height: normal !important; "><u style="word-break: break-all; line-height: normal !important; "><strong style="word-break: break-all; line-height: normal !important; ">安装</strong></u></a>的 MySQL 所支持的字符集等。</p><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">一、查看 MySQL 数据库服务器和数据库字符集。</p><pre class="cmdcode" style="word-break: break-all; line-height: normal; ">mysql&gt; show variables like '%char%';
+--------------------------+-------------------------------------+------
| Variable_name            | Value                               |......
+--------------------------+-------------------------------------+------
| character_set_client     | utf8                                |......   -- 客户端字符集
| character_set_connection | utf8                                |......
| character_set_database   | utf8                                |......   -- 数据库字符集
| character_set_filesystem | binary                              |......
| character_set_results    | utf8                                |......
| character_set_server     | utf8                                |......   -- 服务器字符集
| character_set_system     | utf8                                |......
| character_sets_dir       | D:\MySQL <a href="http://space.itpub.net/8102208/viewspace-605548" target="_self" style="word-break: break-all; text-decoration: underline; color: #070648; line-height: normal; "><u style="word-break: break-all; line-height: normal; "><strong style="word-break: break-all; line-height: normal; ">Server</strong></u></a> 5.0\share\charsets\ |......
+--------------------------+-------------------------------------+------</pre><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">二、查看 MySQL 数据表（table） 的字符集。</p><pre class="cmdcode" style="word-break: break-all; line-height: normal; ">mysql&gt; show table status from sqlstudy_db like '%countries%';
+-----------+--------+---------+------------+------+-----------------+------
| Name      | Engine | Version | Row_format | Rows | Collation       |......
+-----------+--------+---------+------------+------+-----------------+------
| countries | InnoDB |      10 | Compact    |   11 | utf8_general_ci |......
+-----------+--------+---------+------------+------+-----------------+------</pre><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">三、查看 MySQL 数据列（column）的字符集。</p><pre class="cmdcode" style="word-break: break-all; line-height: normal; ">mysql&gt; show full columns from countries;
+----------------------+-------------+-----------------+--------
| Field                | Type        | Collation       | .......
+----------------------+-------------+-----------------+--------
| countries_id         | int(11)     | NULL            | .......
| countries_name       | varchar(64) | utf8_general_ci | .......
| countries_iso_code_2 | char(2)     | utf8_general_ci | .......
| countries_iso_code_3 | char(3)     | utf8_general_ci | .......
| address_format_id    | int(11)     | NULL            | .......
+----------------------+-------------+-----------------+--------</pre><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">四、查看当前安装的 MySQL 所支持的字符集。</p><pre class="cmdcode" style="word-break: break-all; line-height: normal; ">mysql&gt; show charset;
mysql&gt; show char set;
+----------+-----------------------------+---------------------+--------+
| Charset  | Description                 | Default collation   | Maxlen |
+----------+-----------------------------+---------------------+--------+
| big5     | Big5 Traditional Chinese    | big5_chinese_ci     |      2 |
| dec8     | DEC West European           | dec8_swedish_ci     |      1 |
| cp850    | DOS West European           | cp850_general_ci    |      1 |
| hp8      | HP West European            | hp8_english_ci      |      1 |
| koi8r    | KOI8-R Relcom Russian       | koi8r_general_ci    |      1 |
| latin1   | cp1252 West European        | latin1_swedish_ci   |      1 |
| latin2   | ISO 8859-2 Central European | latin2_general_ci   |      1 |
| swe7     | 7bit Swedish                | swe7_swedish_ci     |      1 |
| ascii    | US ASCII                    | ascii_general_ci    |      1 |
| ujis     | EUC-JP Japanese             | ujis_japanese_ci    |      3 |
| sjis     | Shift-JIS Japanese          | sjis_japanese_ci    |      2 |
| hebrew   | ISO 8859-8 Hebrew           | hebrew_general_ci   |      1 |
| tis620   | TIS620 Thai                 | tis620_thai_ci      |      1 |
| euckr    | EUC-KR Korean               | euckr_korean_ci     |      2 |
| koi8u    | KOI8-U Ukrainian            | koi8u_general_ci    |      1 |
| gb2312   | GB2312 Simplified Chinese   | gb2312_chinese_ci   |      2 |
| greek    | ISO 8859-7 Greek            | greek_general_ci    |      1 |
| cp1250   | Windows Central European    | cp1250_general_ci   |      1 |
| gbk      | GBK Simplified Chinese      | gbk_chinese_ci      |      2 |
| latin5   | ISO 8859-9 Turkish          | latin5_turkish_ci   |      1 |
| armscii8 | ARMSCII-8 Armenian          | armscii8_general_ci |      1 |
| utf8     | UTF-8 Unicode               | utf8_general_ci     |      3 |
| ucs2     | UCS-2 Unicode               | ucs2_general_ci     |      2 |
| cp866    | DOS Russian                 | cp866_general_ci    |      1 |
| keybcs2  | DOS Kamenicky Czech-Slovak  | keybcs2_general_ci  |      1 |
| macce    | Mac Central European        | macce_general_ci    |      1 |
| macroman | Mac West European           | macroman_general_ci |      1 |
| cp852    | DOS Central European        | cp852_general_ci    |      1 |
| latin7   | ISO 8859-13 Baltic          | latin7_general_ci   |      1 |
| cp1251   | Windows Cyrillic            | cp1251_general_ci   |      1 |
| cp1256   | Windows Arabic              | cp1256_general_ci   |      1 |
| cp1257   | Windows Baltic              | cp1257_general_ci   |      1 |
| binary   | Binary pseudo charset       | binary              |      1 |
| geostd8  | GEOSTD8 Georgian            | geostd8_general_ci  |      1 |
| cp932    | SJIS for Windows Japanese   | cp932_japanese_ci   |      2 |
| eucjpms  | UJIS for Windows Japanese   | eucjpms_japanese_ci |      3 |
+----------+-----------------------------+---------------------+--------+</pre><p style="word-break: break-all; line-height: 1.8em !important; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">以上查看 MySQL 字符集命令，适用于 Windows &amp; Linux。</p></span><span class="Apple-style-span" style="color: #444444; font-family: 宋体; line-height: 28px; background-color: #ffffff; "><p style="outline-style: none; outline-width: initial; outline-color: initial; line-height: 21px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><br /></p></span><img src ="http://www.blogjava.net/liangcmwn/aggbug/356576.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liangcmwn/" target="_blank">liangcmwn</a> 2011-08-15 16:50 <a href="http://www.blogjava.net/liangcmwn/articles/356576.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql中limit用法 </title><link>http://www.blogjava.net/liangcmwn/articles/355164.html</link><dc:creator>liangcmwn</dc:creator><author>liangcmwn</author><pubDate>Wed, 27 Jul 2011 09:10:00 GMT</pubDate><guid>http://www.blogjava.net/liangcmwn/articles/355164.html</guid><description><![CDATA[<div><div id="app-share-content">  	                    <p>&nbsp; &nbsp; &nbsp; 使用查询语句的时候，经常要返回前几条或者中间某几行数据，这个时候怎么办呢？不用担心，<a target="_self" href="http://hi.baidu.com/%C1%D6%B7%E7%E7%F9/blog/item/:;"><u><strong>mysql</strong></u></a>已 经为我们提供了这样一个功能。</p> <div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; width: 95%; background: none repeat scroll 0% 0% #e6e6e6;"> <div><span style="color: #0000ff;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000ff;">FROM</span> <span style="color: #0000ff;">table</span><span style="color: #000000;">&nbsp;&nbsp;  LIMIT </span><span style="color: #ff0000;">[</span><span style="color: #ff0000;">offset,</span><span style="color: #ff0000;">]</span><span style="color: #000000;"> rows </span><span style="color: #808080;">|</span><span style="color: #000000;"> rows OFFSET offset</span></div> </div> <p><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  LIMIT 子句可以被用于强制 SELECT 语句返回指定的记录数。LIMIT  接受一个或两个数字参数。参数必须是一个整数常量。如果给定两个参数，第一个参数指定第一个返回记录行的偏移量，第二个参数指定返回记录行的最大数目。初  始记录行的偏移量是 0(而不是 1)： 为了与 PostgreSQL 兼容，MySQL 也支持句法： LIMIT # OFFSET #。</p> <div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; width: 95%; background: none repeat scroll 0% 0% #e6e6e6;"> <div><span style="color: #000000;">mysql</span><span style="color: #808080;">&gt;</span> <span style="color: #0000ff;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000ff;">FROM</span> <span style="color: #0000ff;">table</span><span style="color: #000000;"> LIMIT </span><span style="color: #800000; font-weight: bold;">5</span><span style="color: #000000;">,</span><span style="color: #800000; font-weight: bold;">10</span><span style="color: #000000;">;&nbsp;&nbsp;</span><span style="color: #808080;">//</span><span style="color: #000000;"> 检索记录行 </span><span style="color: #800000; font-weight: bold;">6</span><span style="color: #808080;">-</span><span style="color: #800000; font-weight: bold;">15</span><span style="color: #000000;"><br /><br /></span><span style="color: #808080;">//</span><span style="color: #000000;">为了检索从某一个偏移量到记录集的结束所有的记录行，可以指定第二个参数为 </span><span style="color: #808080;">-</span><span style="color: #800000; font-weight: bold;">1</span><span style="color: #000000;">： <br />mysql</span><span style="color: #808080;">&gt;</span> <span style="color: #0000ff;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000ff;">FROM</span> <span style="color: #0000ff;">table</span><span style="color: #000000;"> LIMIT </span><span style="color: #800000; font-weight: bold;">95</span><span style="color: #000000;">,</span><span style="color: #808080;">-</span><span style="color: #800000; font-weight: bold;">1</span><span style="color: #000000;">; </span><span style="color: #808080;">//</span><span style="color: #000000;"> 检索记录行 </span><span style="color: #800000; font-weight: bold;">96</span><span style="color: #808080;">-</span><span style="color: #000000;">last.<br /><br /></span><span style="color: #808080;">//</span><span style="color: #000000;">如果只给定一个参数，它表示返回最大的记录行数目： <br />mysql</span><span style="color: #808080;">&gt;</span> <span style="color: #0000ff;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000ff;">FROM</span> <span style="color: #0000ff;">table</span><span style="color: #000000;"> LIMIT </span><span style="color: #800000; font-weight: bold;">5</span><span style="color: #000000;">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">//</span><span style="color: #000000;">检索前 </span><span style="color: #800000; font-weight: bold;">5</span><span style="color: #000000;"> 个记录行<br /><br /></span><span style="color: #808080;">//</span><span style="color: #000000;">换句话说，LIMIT n 等价于 LIMIT </span><span style="color: #800000; font-weight: bold;">0</span><span style="color: #000000;">,n。</span></div> </div> <p> </p> <p> </p> <p><strong>实例：</strong></p> <p>mysql&gt; use sppeivan;<br /> Database changed<br /> mysql&gt; select * from employee; <strong> // 返回所有结果</strong><br /> +------------+------------+--------+-------------+<br /> | username&nbsp;&nbsp;  | password&nbsp;&nbsp;  | gender | cellphone&nbsp;&nbsp;  |<br /> +------------+------------+--------+-------------+<br /> | ewrew&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | erewr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ewrwerw32r | 324324&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | grrrrr&nbsp;&nbsp;&nbsp;&nbsp;  | r44343&nbsp;&nbsp;&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | pansong&nbsp;&nbsp;&nbsp;  | erewrwe&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ret43t43t  | 43t43&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ret44t4&nbsp;&nbsp;&nbsp;  | r4tgr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | tttt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | 4et&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | wr34r&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | retre&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | xxx&nbsp;&nbsp;&nbsp;&nbsp;  | safe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | hhh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | ewrwer&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | hg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | 6574326543 | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ps&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | ewrwe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | zhu&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | werew&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> +------------+------------+--------+-------------+<br /> 13 rows in set (0.01 sec)</p> <p>mysql&gt; select * from employee limit 3 7;<br /> ERROR 1064 (42000): You have an error in your SQL syntax<br /> corresponds to your MySQL server version for the right s<br />  line 1<br /> mysql&gt; select * from employee limit 3, 7;  <strong>// 返回4-11行</strong><br /> +-----------+----------+--------+-------------+<br /> | username  | password | gender | cellphone&nbsp;&nbsp;  |<br /> +-----------+----------+--------+-------------+<br /> | pansong&nbsp;&nbsp;  | erewrwe  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ret43t43t | 43t43&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ret44t4&nbsp;&nbsp;  | r4tgr&nbsp;&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | tttt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | 4et&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | wr34r&nbsp;&nbsp;&nbsp;&nbsp;  | retre&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | xxx&nbsp;&nbsp;&nbsp;&nbsp;  | safe&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | hhh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | ewrwer&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> +-----------+----------+--------+-------------+<br /> 7 rows in set (0.00 sec)</p> <p>mysql&gt; select * from employee limit 3,-1;  <strong>// 错误语法</strong><br /> ERROR 1064 (42000): You have an error in your SQL syntax<br /> corresponds to your MySQL server version for the right s<br /> t line 1</p> <p><br /> mysql&gt; select * from employee limit 3,1;  <strong>// 返回第4行</strong><br /> +----------+----------+--------+-------------+<br /> | username | password | gender | cellphone&nbsp;&nbsp;  |<br /> +----------+----------+--------+-------------+<br /> | pansong  | erewrwe  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076|<br /> +----------+----------+--------+-------------+<br /> 1 row in set (0.00 sec)</p> <p>mysql&gt; select * from employee limit 3; <strong>// 返回前3行</strong><br /> <br /> +------------+----------+--------+-------------+<br /> | username&nbsp;&nbsp;  | password | gender | cellphone&nbsp;&nbsp;  |<br /> +------------+----------+--------+-------------+<br /> | ewrew&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | erewr&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ewrwerw32r | 324324&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | grrrrr&nbsp;&nbsp;&nbsp;&nbsp;  | r44343&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> +------------+----------+--------+-------------+<br /> 3 rows in set (0.00 sec)</p> <p><br /> mysql&gt; select * from employee limit 10; <strong>// 返回前10行</strong><br /> <br /> +------------+----------+--------+-------------+<br /> | username&nbsp;&nbsp;  | password | gender | cellphone&nbsp;&nbsp;  |<br /> +------------+----------+--------+-------------+<br /> | ewrew&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | erewr&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ewrwerw32r | 324324&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | grrrrr&nbsp;&nbsp;&nbsp;&nbsp;  | r44343&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | pansong&nbsp;&nbsp;&nbsp;  | erewrwe  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ret43t43t  | 43t43&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | ret44t4&nbsp;&nbsp;&nbsp;  | r4tgr&nbsp;&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | tttt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | 4et&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | WOMAN  | 13618889076 |<br /> | wr34r&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | retre&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> | xxx&nbsp;&nbsp;&nbsp;&nbsp;  | safe&nbsp;&nbsp;&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13811588469 |<br /> | hhh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  | ewrwer&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13618889076 |<br /> +------------+----------+--------+-------------+<br /> 10 rows in set (0.00 sec)</p> <p>mysql&gt; select * from employee limit 9,1;  <strong>// 返回第10行</strong><br /> <br /> +----------+----------+--------+-------------+<br /> | username | password | gender | cellphone&nbsp;&nbsp;  |<br /> +----------+----------+--------+-------------+<br /> | hhh&nbsp;&nbsp;&nbsp;&nbsp;  | ewrwer&nbsp;&nbsp;  | MAN&nbsp;&nbsp;&nbsp;  | 13816668468 |<br /> +----------+----------+--------+-------------+<br /> 1 row in set (0.00 sec)</p>             			</div></div><img src ="http://www.blogjava.net/liangcmwn/aggbug/355164.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liangcmwn/" target="_blank">liangcmwn</a> 2011-07-27 17:10 <a href="http://www.blogjava.net/liangcmwn/articles/355164.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>