﻿<?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-Jafe Lee</title><link>http://www.blogjava.net/JafeLee/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 28 Apr 2026 14:32:28 GMT</lastBuildDate><pubDate>Tue, 28 Apr 2026 14:32:28 GMT</pubDate><ttl>60</ttl><item><title>ubuntu 8.04 安装 MySQL 5.0</title><link>http://www.blogjava.net/JafeLee/archive/2008/06/14/207840.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Sat, 14 Jun 2008 03:26:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2008/06/14/207840.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/207840.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2008/06/14/207840.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/207840.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/207840.html</trackback:ping><description><![CDATA[1、直接apt-get 安装：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">5.0</span></div><br />2、安装启动后出现错误信息：（中文）<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(128, 128, 128);">*</span><span style="color: rgb(0, 0, 0);"> Stopping MySQL </span><span style="color: rgb(0, 0, 255);">database</span><span style="color: rgb(0, 0, 0);"> server mysqld </span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);"> OK </span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);"><br />安装mysql 时出现下列错误，请教高手！<br /></span><span style="color: rgb(128, 128, 128);">*</span><span style="color: rgb(0, 0, 0);"> Starting MySQL </span><span style="color: rgb(0, 0, 255);">database</span><span style="color: rgb(0, 0, 0);"> server mysqld </span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">fail</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);"><br />invoke</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">rc.d: initscript mysql, action "start" failed.<br />dpkg：处理 mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">5.0</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">configure)时出错：</span><span style="color: rgb(0, 128, 128);"><br /></span><span style="color: rgb(0, 0, 0);">子进程 post</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">installation script 返回了错误号 </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);"><br />dpkg：依赖关系问题使得 mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server 的配置工作不能继续：<br />mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server 依赖于 mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">5.0</span><span style="color: rgb(0, 0, 0);">；然而：<br />软件包 mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">5.0</span><span style="color: rgb(0, 0, 0);"> 还没有被配置。<br />dpkg：处理 mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server (</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">configure)时出错：</span><span style="color: rgb(0, 128, 128);"><br /></span><span style="color: rgb(0, 0, 0);">依赖关系问题 </span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);"> 仍未被配置<br />Processing triggers </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> libc6 <img src="http://www.blogjava.net/images/dot.gif" /><br />ldconfig deferred processing now taking place<br />在处理时有错误发生：<br />mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">5.0</span><span style="color: rgb(0, 0, 0);"><br />mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">server<br />E: Sub</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">process </span><span style="color: rgb(128, 128, 128);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(128, 128, 128);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(128, 128, 128);">/</span><span style="color: rgb(0, 0, 0);">dpkg returned an error code (</span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">)</span></div><br />英文错误信息是：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">invoke</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">rc.d: initscript apparmor, action </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">force-reload</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> failed.<br /></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> Starting MySQL database server mysqld<br /><img src="http://www.blogjava.net/images/dot.gif" />fail</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);"><br />invoke</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">rc.d: initscript mysql, action </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">start</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> failed.<br />dpkg: error processing mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">5.0</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">configure):<br />subprocess post</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">installation script returned error exit status </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"><br />dpkg: dependency problems prevent configuration of mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server:<br />mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server depends on mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">5.0</span><span style="color: rgb(0, 0, 0);">; however:<br />Package mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">5.0</span><span style="color: rgb(0, 0, 0);"> is not configured yet.<br />dpkg: error processing mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server (</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">configure):<br />dependency problems </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> leaving unconfigured<br />Errors were encountered </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> processing:<br />mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">5.0</span><span style="color: rgb(0, 0, 0);"><br />mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server<br />E: Sub</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">process </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">dpkg returned an error code (</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)</span></div>出现错误的原因是我修改了ubuntu的默认网络设置（<span class="postbody">/etc/network/interfaces
）</span>，删除了ubuntu的<span class="postbody">loopback接口，我的解决方法如下：</span><br /><span class="postbody">ubuntu原来默认设置：</span><br /><span class="postbody"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">auto lo<br />iface lo inet loopback <br /></span></div>被我修改成静态ip：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">auto eth0<br />iface eth0 inet static<br />address </span><span style="color: rgb(128, 0, 0); font-weight: bold;">10.100</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">24.31</span><span style="color: rgb(0, 0, 0);"><br />netmask </span><span style="color: rgb(128, 0, 0); font-weight: bold;">255.255</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">255.0</span><span style="color: rgb(0, 0, 0);"><br />gateway </span><span style="color: rgb(128, 0, 0); font-weight: bold;">10.100</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">24.254</span><span style="color: rgb(0, 0, 0);"><br /></span></div></span>将上面两部分合起来就可以增加一个Loopback接口<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">auto eth0<br />iface eth0 inet static<br />address </span><span style="color: rgb(128, 0, 0); font-weight: bold;">10.100</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">24.31</span><span style="color: rgb(0, 0, 0);"><br />netmask </span><span style="color: rgb(128, 0, 0); font-weight: bold;">255.255</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">255.0</span><span style="color: rgb(0, 0, 0);"><br />gateway </span><span style="color: rgb(128, 0, 0); font-weight: bold;">10.100</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">24.254</span><span style="color: rgb(0, 0, 0);"><br /><br />auto lo<br />iface lo inet loopback </span></div>重启系统，这时再安装mysql-server就ok了~<br /><br />3、允许其他机器连接、访问到数据库：<br />修改文件 /etc/mysql/my.cnf，将<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">bind</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">address</span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(128, 0, 0); font-weight: bold;">127.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0.1</span></div>改为<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">bind</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">address</span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0.0</span></div>这样将允许所有ip访问数据库<br /><br />参考资料：<a href="http://forum.ubuntu.org.cn/viewtopic.php?p=757703">http://forum.ubuntu.org.cn/viewtopic.php?p=757703</a><br /><a href="http://blog.csdn.net/redvalley/archive/2008/04/27/2333702.aspx"> http://blog.csdn.net/redvalley/archive/2008/04/27/2333702.aspx</a><br />问题2也可以参考一下<a href="http://blog.csdn.net/redvalley/archive/2008/04/27/2333702.aspx">这里</a>的方法，似乎更简单，也不用改动network设置，不过不知可不可以，没验证过~<br /><img src ="http://www.blogjava.net/JafeLee/aggbug/207840.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2008-06-14 11:26 <a href="http://www.blogjava.net/JafeLee/archive/2008/06/14/207840.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用Java方法解决Groovy 中文乱码</title><link>http://www.blogjava.net/JafeLee/archive/2008/06/09/206835.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Mon, 09 Jun 2008 14:35:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2008/06/09/206835.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/206835.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2008/06/09/206835.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/206835.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/206835.html</trackback:ping><description><![CDATA[从网上copy了一些文本，出现了很多空行，脚本作用就是把空行去掉，代码如下<br /><br /><pre><font><font color="#000000">writer <font color="#000000"><strong>=</strong></font><font color="#006699"><strong>new</strong></font><font color="#9966ff">FileWriter</font><font color="#000000"><strong>(</strong></font><font color="#ff00cc">"</font><font color="#ff00cc">output</font><font color="#ff00cc">.</font><font color="#ff00cc">txt</font><font color="#ff00cc">"</font><font color="#000000"><strong>)</strong></font><br /><font color="#006699"><strong>new</strong></font><font color="#9966ff">File</font><font color="#000000"><strong>(</strong></font><font color="#ff00cc">"</font><font color="#ff00cc">Hello</font><font color="#ff00cc">.</font><font color="#ff00cc">txt</font><font color="#ff00cc">"</font><font color="#000000"><strong>)</strong></font>.<font color="#66ccff"><strong>eachLine</strong></font> { <br />    line <font color="#000000"><strong>-&gt;</strong></font><font color="#006699"><strong>if</strong></font><font color="#000000"><strong>(</strong></font>line <font color="#000000"><strong>!</strong></font><font color="#000000"><strong>=</strong></font><font color="#ff00cc">'</font><font color="#ff00cc">'</font><font color="#000000"><strong>)</strong></font> {<br />        writer.<font color="#66ccff"><strong>write</strong></font><font color="#000000"><strong>(</strong></font><font color="#000000"><strong>(</strong></font><font color="#006699"><strong>new</strong></font><font color="#9966ff">String</font><font color="#000000"><strong>(</strong></font>line.<font color="#9966ff">getBytes</font><font color="#000000"><strong>(</strong></font><font color="#ff00cc">"</font><font color="#ff00cc">GBK</font><font color="#ff00cc">"</font><font color="#000000"><strong>)</strong></font><font color="#000000"><strong>)</strong></font><font color="#000000"><strong>)</strong></font><font color="#000000"><strong>+</strong></font><font color="#ff00cc">'</font><font color="#ff00cc">r\n</font><font color="#ff00cc">'</font><font color="#000000"><strong>)</strong></font><br />    }<br />}<br />writer.<font color="#9966ff">close</font><font color="#000000"><strong>(</strong></font><font color="#000000"><strong>)</strong></font></font></font></pre><br />脚本很简单，不过刚开始没考虑中文编码问题，结果出现了乱码。Google了一下 groovy中文乱码，不过没找到相关问题，再Google java中文乱码，结果用java的解决方法真的解决了Groovy中文乱码问题。这从一定程度上也反映了Java和Groovy的结合程度吧<br />对java程序员来说，groovy真的是一门不错的脚本语言，由于基本语法极其相似，所以也不用花太多时间在语言学习上面，而且还可以直接使用java api。<br />不过groovy也有一些明显的缺点，例如速度慢等，不过这些应该会越来越好的。还有，觉得还有一点不如python，就是自己的类库有点偏少了，毕竟跟python相比，groovy还很年轻。不过这可能是由于初步使用groovy，所以还没完全领会到它的威力~<br />以前觉得groovy的速度会成为它发展的瓶颈，不过现在对groovy的发展充满了信心<br /><br /><img src ="http://www.blogjava.net/JafeLee/aggbug/206835.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2008-06-09 22:35 <a href="http://www.blogjava.net/JafeLee/archive/2008/06/09/206835.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Groovy语法学习 (1)</title><link>http://www.blogjava.net/JafeLee/archive/2008/06/05/206155.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Thu, 05 Jun 2008 13:19:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2008/06/05/206155.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/206155.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2008/06/05/206155.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/206155.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/206155.html</trackback:ping><description><![CDATA[1、注释。Groovy有四种类型的注释<br /><ul><li>#! 型注释：这种注释只能出现在脚本文件的第一行，用来提示语言解释器的位置，例如<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">!/usr/bin/groovy</span></div></li><li><span style="color: rgb(0, 128, 0);"><font color="#000000">单行注释 ，以 // 开头</font></span></li><li><span style="color: rgb(0, 128, 0);"><font color="#000000">多行注释，包含在 /*    */ 之间</font></span></li><li><span style="color: rgb(0, 128, 0);"><font color="#000000">类似javadoc的注释  /**   */</font></span></li></ul>2、标准输出、输入<br /><ul><li>输出到控制台：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><pre><font color="#000000"><font color="#009966"><strong>def</strong></font> age <font color="#000000"><strong>=</strong></font><font color="#ff0000">25</font><br /><font color="#66ccff"><strong>print</strong></font><font color="#ff00cc">"</font><font color="#ff00cc">My</font><font color="#ff00cc"></font><font color="#ff00cc">age</font><font color="#ff00cc"></font><font color="#ff00cc">is</font><font color="#ff00cc">:</font><font color="#ff00cc"></font><font color="#ff00cc">"</font><br /><font color="#66ccff"><strong>println</strong></font> age<br /><font color="#66ccff"><strong>println</strong></font><font color="#ff00cc">"</font><font color="#ff00cc">My</font><font color="#ff00cc"></font><font color="#ff00cc">age</font><font color="#ff00cc"></font><font color="#ff00cc">is</font><font color="#ff00cc">:</font><font color="#ff00cc"></font><font color="#009966"><strong>${</strong></font><font color="#009966"><strong>age</strong></font><font color="#009966"><strong>}</strong></font><font color="#ff00cc">"</font></font></pre></div></li><li><span style="color: rgb(0, 0, 0);">从键盘输入<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><pre><font color="#000000"><font color="#66ccff"><strong>print</strong></font><font color="#ff00cc">"</font><font color="#ff00cc">Please</font><font color="#ff00cc"></font><font color="#ff00cc">enter</font><font color="#ff00cc"></font><font color="#ff00cc">your</font><font color="#ff00cc"></font><font color="#ff00cc">name</font><font color="#ff00cc">:</font><font color="#ff00cc"></font><font color="#ff00cc">"</font><br />name <font color="#000000"><strong>=</strong></font><font color="#006699"><strong>new</strong></font><font color="#9966ff">InputStreamReader</font><font color="#000000"><strong>(</strong></font>System.<font color="#009966"><strong>in</strong></font><font color="#000000"><strong>)</strong></font>.<font color="#9966ff">readLine</font><font color="#000000"><strong>(</strong></font><font color="#000000"><strong>)</strong></font><br /><font color="#66ccff"><strong>println</strong></font><font color="#ff00cc">"</font><font color="#ff00cc">My</font><font color="#ff00cc"></font><font color="#ff00cc">name</font><font color="#ff00cc"></font><font color="#ff00cc">is</font><font color="#ff00cc">:</font><font color="#ff00cc"></font><font color="#009966"><strong>${</strong></font><font color="#009966"><strong>name</strong></font><font color="#009966"><strong>}</strong></font><font color="#ff00cc">"</font></font></pre><span style="color: rgb(0, 0, 0);"></span></div><br /></span></li></ul><img src ="http://www.blogjava.net/JafeLee/aggbug/206155.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2008-06-05 21:19 <a href="http://www.blogjava.net/JafeLee/archive/2008/06/05/206155.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java 正则表达式 (3) -- Quantifiers</title><link>http://www.blogjava.net/JafeLee/archive/2007/12/10/166811.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Mon, 10 Dec 2007 14:35:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/12/10/166811.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/166811.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/12/10/166811.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/166811.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/166811.html</trackback:ping><description><![CDATA[
		<br />1、Java 正则表达式中的Quantifiers（量词）使用来指定匹配字符出现的次数的，java api中有三种Quantifiers: greedy, reluctant, and possessive。虽然三种quantifiers的作用很相似（见下表），但是三者还是有区别的。（摘自<a href="http://java.sun.com/docs/books/tutorial/essential/regex/quant.html">java.sun.com</a>）<br /><br /><div align="center"><table border="1" cellpadding="0" cellspacing="2" height="208" width="546"><tbody><tr><td colspan="3" bgcolor="#dedeef"><center><b>Quantifiers</b></center></td><td rowspan="2" bgcolor="#dedeef" width="48%"><b> Meaning</b></td></tr><tr><td bgcolor="#ffe1e1" height="23" width="16%">
     <b>Greedy</b></td><td bgcolor="#e9fceb" height="23" width="16%">
     <b>Reluctant</b></td><td bgcolor="#ffffdb" height="23" width="16%">
     <b>Possessive</b></td></tr><tr><td bgcolor="#ffe1e1" height="23" width="16%">
     <code>X?</code></td><td bgcolor="#e9fceb" width="16%">
     <code>X??</code></td><td bgcolor="#ffffdb" width="16%">
     <code>X?+</code></td><td bgcolor="#dedeef" height="23" width="48%">
     <code><i>X</i></code>, once or not at all</td></tr><tr><td bgcolor="#ffe1e1" height="23" width="16%">
     <code>X*</code></td><td bgcolor="#e9fceb" width="18%">
     <code>X*?</code></td><td bgcolor="#ffffdb" width="16%">
     <code>X*+</code></td><td bgcolor="#dedeef" height="23" width="48%">
     <code><i>X</i></code>, zero or more times</td></tr><tr><td bgcolor="#ffe1e1" height="23" width="16%">
     <code>X+</code></td><td bgcolor="#e9fceb" width="18%">
     <code>X+?</code></td><td bgcolor="#ffffdb" width="16%">
     <code>X++</code></td><td bgcolor="#dedeef" height="23" width="48%">
     <code><i>X</i></code>, one or more times</td></tr><tr><td bgcolor="#ffe1e1" height="24" width="16%">
     <code>X{n} </code></td><td bgcolor="#e9fceb" width="16%">
     <code>X{n}? </code></td><td bgcolor="#ffffdb" width="18%">
     <code>X{n}+ </code></td><td bgcolor="#dedeef" height="24" width="48%">
     <code><i>X</i></code>, exactly <i><code>n</code></i> times</td></tr><tr><td bgcolor="#ffe1e1" height="24" width="16%">
     <code>X{n,}</code></td><td bgcolor="#e9fceb" width="18%">
     <code>X{n,}?</code></td><td bgcolor="#ffffdb" width="16%">
     <code>X{n,}+</code></td><td bgcolor="#dedeef" height="24" width="48%">
     <code><i>X</i></code>, at least <i><code>n</code></i> times</td></tr><tr><td bgcolor="#ffe1e1" height="24" width="16%">
     <code>X{n,m}</code></td><td bgcolor="#e9fceb" width="16%">
     <code>X{n,m}?</code></td><td bgcolor="#ffffdb" width="18%">
     <code>X{n,m}+</code></td><td bgcolor="#dedeef" height="24" width="48%">
     <code><i>X</i></code>, at least <i><code>n</code></i> but not
    more than <i><code>m</code></i> times</td></tr></tbody></table></div><br /><br />2、几个例子（摘自 <a href="http://java.sun.com/docs/books/tutorial/essential/regex/quant.html">java.sun.com</a>）<br /><ul><li><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_223435" onclick="this.style.display='none'; Code_Closed_Text_223435.style.display='none'; Code_Open_Image_223435.style.display='inline'; Code_Open_Text_223435.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_223435" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_223435.style.display='none'; Code_Closed_Image_223435.style.display='inline'; Code_Closed_Text_223435.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">greedy quantifiers</span><span id="Code_Open_Text_223435" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: a</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: <br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: <br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: <br />No match found.</span></span></div></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_223507" onclick="this.style.display='none'; Code_Closed_Text_223507.style.display='none'; Code_Open_Image_223507.style.display='inline'; Code_Open_Text_223507.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_223507" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_223507.style.display='none'; Code_Closed_Image_223507.style.display='inline'; Code_Closed_Text_223507.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">Zero-Length Matches (1)</span><span id="Code_Open_Text_223507" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: a</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: a<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: a<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: a<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.</span></span></div></span></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_223600" onclick="this.style.display='none'; Code_Closed_Text_223600.style.display='none'; Code_Open_Image_223600.style.display='inline'; Code_Open_Text_223600.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_223600" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_223600.style.display='none'; Code_Closed_Image_223600.style.display='inline'; Code_Closed_Text_223600.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_223600" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">Zero-Length Matches (2)</span><span id="Code_Open_Text_223600" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: a</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: aaaaa<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: aaaaa<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaaaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: aaaaa<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaaaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">.</span></span></div></span></span></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223600" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_223645" onclick="this.style.display='none'; Code_Closed_Text_223645.style.display='none'; Code_Open_Image_223645.style.display='inline'; Code_Open_Text_223645.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_223645" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_223645.style.display='none'; Code_Closed_Image_223645.style.display='inline'; Code_Closed_Text_223645.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_223645" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">Zero-Length Matches (3)</span><span id="Code_Open_Text_223645" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: a</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: ababaaaab<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">7</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">7</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: ababaaaab<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"><br />Enter input string to search: ababaaaab<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">.</span></span></div></span></span></span></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223600" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223645" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_223923" onclick="this.style.display='none'; Code_Closed_Text_223923.style.display='none'; Code_Open_Image_223923.style.display='inline'; Code_Open_Text_223923.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_223923" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_223923.style.display='none'; Code_Closed_Image_223923.style.display='inline'; Code_Closed_Text_223923.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_223923" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">exactly n number of times</span><span id="Code_Open_Text_223923" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: a{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">}<br />Enter input string to search: aa<br />No match found.<br /><br />Enter your regex: a{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">}<br />Enter input string to search: aaa<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: a{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">}<br />Enter input string to search: aaaa<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.</span></span></div></span></span></span></span></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223600" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223645" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223923" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_224049" onclick="this.style.display='none'; Code_Closed_Text_224049.style.display='none'; Code_Open_Image_224049.style.display='inline'; Code_Open_Text_224049.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_224049" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_224049.style.display='none'; Code_Closed_Image_224049.style.display='inline'; Code_Closed_Text_224049.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_224049" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">at least n times</span><span id="Code_Open_Text_224049" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: a{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">,}<br />Enter input string to search: aaaaaaaaa<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaaaaaaaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">.</span></span></div></span></span></span></span></span></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223600" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223645" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223923" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_224049" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_224127" onclick="this.style.display='none'; Code_Closed_Text_224127.style.display='none'; Code_Open_Image_224127.style.display='inline'; Code_Open_Text_224127.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_224127" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_224127.style.display='none'; Code_Closed_Image_224127.style.display='inline'; Code_Closed_Text_224127.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_224127" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">an upper limit </span><span id="Code_Open_Text_224127" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: a{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">} </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> find at least 3 (but no more than 6) a's in a row</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">Enter input string to search: aaaaaaaaa<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaaaaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">.</span></span></div></span></span></span></span></span></span></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223600" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223645" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223923" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_224049" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_224127" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_160456" onclick="this.style.display='none'; Code_Closed_Text_160456.style.display='none'; Code_Open_Image_160456.style.display='inline'; Code_Open_Text_160456.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_160456" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_160456.style.display='none'; Code_Closed_Image_160456.style.display='inline'; Code_Closed_Text_160456.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_160456" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">Capturing Groups with Quantifiers</span><span id="Code_Open_Text_160456" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: (dog){</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">}<br />Enter input string to search: dogdogdogdogdogdog<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">dogdogdog</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">dogdogdog</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">18</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: dog{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">}<br />Enter input string to search: dogdogdogdogdogdog<br />No match found.</span></span></div></span></span></span></span></span></span></span></li><li><span id="Code_Closed_Text_223435" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223507" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223600" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223645" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_223923" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_224049" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_224127" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><span id="Code_Closed_Text_160456" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_160546" onclick="this.style.display='none'; Code_Closed_Text_160546.style.display='none'; Code_Open_Image_160546.style.display='inline'; Code_Open_Text_160546.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_160546" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_160546.style.display='none'; Code_Closed_Image_160546.style.display='inline'; Code_Closed_Text_160546.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_160546" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">Character Class with Quantifiers</span><span id="Code_Open_Text_160546" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Enter your regex: [abc]{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">}<br />Enter input string to search: abccabaaaccbbbc<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">abc</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">cab</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">aaa</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">ccb</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">12</span><span style="color: rgb(0, 0, 0);">.<br />I found the text </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bbc</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> starting at index </span><span style="color: rgb(0, 0, 0);">12</span><span style="color: rgb(0, 0, 0);"> and ending at index </span><span style="color: rgb(0, 0, 0);">15</span><span style="color: rgb(0, 0, 0);">.<br /><br />Enter your regex: abc{</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">}<br />Enter input string to search: abccabaaaccbbbc<br />No match found.</span></span></div></span></span></span></span></span></span></span></span></li></ul><br /><img src ="http://www.blogjava.net/JafeLee/aggbug/166811.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-12-10 22:35 <a href="http://www.blogjava.net/JafeLee/archive/2007/12/10/166811.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java 正则表达式 (2) -- Metacharacters &amp; Character Classes</title><link>http://www.blogjava.net/JafeLee/archive/2007/12/10/166494.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Mon, 10 Dec 2007 01:58:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/12/10/166494.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/166494.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/12/10/166494.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/166494.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/166494.html</trackback:ping><description><![CDATA[1、元字符(metacharacters):元字符是指那些可以代表特殊含义的字符，java.util.regex支持的元字符包括<font color="#0000ff"><code>([{\^-$|]})?*+.<font color="#000000">。注意，在某些时候这些特殊的字符并不一定代表特殊含义，例如 - 在[a-c]中是元字符，但在 a-c 则不表示特殊含义。不过上面没列出的字符则一定不会代表特殊含义。<br /><br />2、可以对元字符进行转义，主要有两种方法：<br /></font></code></font><ul><li>在元字符前面加一个反斜杠 (backslash）\ <br /></li><li>用 \Q 和 \E包含起来，例如 \? == \Q?\E</li></ul>3、Character Classes ：这里的class并不是Java中的class，在正则表达式中，一个character class是由一系列包含在方括号中的字符组成，它能在输入的一系列字符串中匹配一个字符，例如[a-d]匹配a, b, c, d,中的任何一个字符。再看下面一个例子（摘自<a href="http://java.sun.com/docs/books/tutorial/essential/regex/char_classes.html">java.sun.com</a>）<br /><div align="center"><br /></div><table align="center" border="1"><tbody><tr><td colspan="2"><b><center>Character Classes</center></b></td></tr><tr><td><code>[abc]</code></td><td>
a, b, or c (simple class)
</td></tr><tr><td><code>[^abc]</code></td><td>          
Any character except a, b, or c (negation)
</td></tr><tr><td><code>[a-zA-Z] </code></td><td>          
a through z, or A through Z, inclusive (range)
</td></tr><tr><td><code>[a-d[m-p]] </code></td><td>          
a through d, or m through p: [a-dm-p] (union)
</td></tr><tr><td><code> [a-z&amp;&amp;[def]]</code></td><td>          
d, e, or f (intersection)
</td></tr><tr><td><code>[a-z&amp;&amp;[^bc]]</code></td><td>          
a through z, except for b and c: [ad-z] (subtraction)
</td></tr><tr><td><code>[a-z&amp;&amp;[^m-p]] </code></td><td>          
a through z, and not m through p: [a-lq-z] (subtraction)</td></tr></tbody></table><br />4、Character Classes 之间的运算：从上面的表格也可以看出 character classes包含了几个跟集合操作很相似的操作：例如negation（补）、union(并）、intersection(交）、subtraction(差）。由上面的表格也可以看出两个Character Classes之间的运算只需要简单地将一个Character Classes嵌入到另一个Character Classes并使用正确的操作符就可以了。<br /><br />5、Predefined Character Classes：java.util.regex.* 包含了一些预先定义的 Character Classes,在实际中可以很方便地运用：（摘自 <a href="http://java.sun.com/docs/books/tutorial/essential/regex/pre_char_classes.html">java.sun.com</a> )<br /><br /><div align="center"><table border="1"><tbody><tr><td colspan="2"><center><b>Predefined Character Classes</b></center></td></tr><tr><td width="15"><code>. </code></td><td>
Any character (may or may not match line terminators)
</td></tr><tr><td><code>\d</code></td><td>         
A digit: <code>[0-9]</code></td></tr><tr><td><code>\D</code></td><td>         
A non-digit: <code>[^0-9]</code></td></tr><tr><td><code>\s</code></td><td>         
A whitespace character: <code>[ \t\n\x0B\f\r]</code></td></tr><tr><td><code>\S</code></td><td>         
A non-whitespace character: <code>[^\s]</code></td></tr><tr><td><code>\w</code></td><td>         
A word character: <code>[a-zA-Z_0-9]</code></td></tr><tr><td><code>\W</code></td><td>         A non-word character: <code>[^\w]</code></td></tr></tbody></table><div align="left"><br /></div></div><img src ="http://www.blogjava.net/JafeLee/aggbug/166494.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-12-10 09:58 <a href="http://www.blogjava.net/JafeLee/archive/2007/12/10/166494.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java 正则表达式 (1)  --  java.util.regex.*  介绍</title><link>http://www.blogjava.net/JafeLee/archive/2007/12/09/166489.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Sun, 09 Dec 2007 11:47:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/12/09/166489.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/166489.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/12/09/166489.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/166489.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/166489.html</trackback:ping><description><![CDATA[1、Java 1.4之后的版本引进了一个用于处理正则表达式的包 java.util.regex.*; 该包主要包含三个类：<br /><ul><li><font color="#0000ff">Pattern</font> : 用来表示一个经过编译处理后的正则表达式。通俗一点来说，就是用一个类来表示一个正则表达式，这个类是从正则表达式构造得到的。这个类并没有public constructor, 如果想得到一个这个类的一个对象则必须调用该类的public static方法：public static Pattern compile(String regex)或者 public static Pattern compile(String regex,int flags)。这两个方法返回一个Pattern型的对象。</li><li><font color="#0000ff">Matcher</font> : 解释Pattern并执行匹配、查找工作的类，跟Pattern类一样，这个类也没有定义public constructor，要想获得一个Matcher对象必须调用Pattern类的方法 public Matcher matcher(CharSequence input) 来得到。</li><li><font color="#0000ff">PatternSyntaxException</font> : 一个unchecked exception。当遇到不符和Java正则表达式的语法的时候程序就会抛出这个异常。</li></ul>2、一个例子（摘自<a href="http://java.sun.com/docs/books/tutorial/essential/regex/examples/RegexTestHarness.java">java.sun.com</a> ）<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> regex;<br /></span><span style="color: rgb(0, 0, 255);"><br />import</span><span style="color: rgb(0, 0, 0);"> java.io.Console;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.regex.Pattern;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.regex.Matcher;</span><span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> RegexTestHarness {<br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main(String [] args) {<br />        Console console </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> System.console();<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (console </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">) {<br />            System.err.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">No console.</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />            System.exit(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">) {<br />            Pattern pattern </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(console.readLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%nEnter your regex: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br />            Matcher matcher </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pattern.matcher(console.readLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Enter input string to search: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br />            </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> found </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br />            </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> (matcher.find()) {<br />                console.format(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">I found the text \</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);">s\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">starting at </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"><br />                        </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">index %d and ending at index %d. %n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, matcher.group(), matcher.start(), matcher.end());<br />                found </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br />            }<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">found)<br />                console.format(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">No match found.%n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        }<br />    }<br />}<br /></span></div>注：由于这个例子使用了JDK 1.6后才有的方法：System.console(),所以这个例子在eclipse和netbeans都不能正常运行。只有在命令行下才能正确运行。如果想在eclipse和nb下运行，好像可以用System.out/in来代替System.console。<br /><img src ="http://www.blogjava.net/JafeLee/aggbug/166489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-12-09 19:47 <a href="http://www.blogjava.net/JafeLee/archive/2007/12/09/166489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用VC的一些问题</title><link>http://www.blogjava.net/JafeLee/archive/2007/10/11/151932.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Thu, 11 Oct 2007 01:20:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/10/11/151932.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/151932.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/10/11/151932.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/151932.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/151932.html</trackback:ping><description><![CDATA[最近做的东西都要用vc，很多错误都莫名， sigh。。。 Java真好！<br />1、error C2146: syntax error : missing ';' before identifier 'ContextRecord'<br />c:\program files\psdk\include\winnt.h(3393) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br />c:\program files\psdk\include\winnt.h(3393) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br /><br />原因：忘记包含头文件 windows.h了~<br />解决方法：包含头文件  windows.h <br /><img src ="http://www.blogjava.net/JafeLee/aggbug/151932.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-10-11 09:20 <a href="http://www.blogjava.net/JafeLee/archive/2007/10/11/151932.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Visual Studio 2005 Express 下的 WinPcap 配置</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/27/148719.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Thu, 27 Sep 2007 06:55:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/27/148719.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/148719.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/27/148719.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/148719.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/148719.html</trackback:ping><description><![CDATA[因网络课程的作业需要用到winpcap，不得已又要和C++打交道了。由于winpcap是为vc而设计的，但是我又不大喜欢用盗版，于是打算用免费的 VC++ 2005 Express版。<br /><br />1、安装 Visual Studio 2005 Express Edition 和 Paltform SDK。<br /><br />如何安装Visual Studio 2005 Express在这里就不赘述了，很简单的。由于VC Express没有自带 Platform SDK,所以需要自己下载安装（如果不安装 psdk的话，就会出现 找不到 winsock2.h 的编译错误）。由于微软现在官网提供的psdk下载比较麻烦，需要windows正版验证，再加上体积比较大，所以我这里就不用，我用的psdk是在这里下载的：<br /><a href="http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm">XPSP2 PSDK Full Download with Local Install</a><br />还有一个，不知道能不能安装在xp上，有兴趣的兄弟可以自己试试<br /><a href="http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm">Windows Server 2003 PSDK Full Download with Local Install</a><br />似乎这两个链接在官网上是找不到的<br />下载、解压、安装，然后再配置 VC++：<br />tools --&gt; options  --&gt; Projects and Solutions  --&gt; VC++ Directories   : 把以下路径添加到相应的下拉节点中去：(其中psdk是你的sdk安装目录）<br /><ul><li><p>Executalbe files ：<tt>psdkdir\Bin</tt></p></li><li><p>Include files ：<tt>psdkdir</tt><tt>\include</tt></p></li><li><p>Library files：<tt>psdkdir</tt><tt>\lib</tt></p></li></ul>2、安装 winpcap:到这里下载 <a href="http://www.winpcap.org/install/bin/WinPcap_4_0_1.exe">winpcap</a><br />安装后按要求重启，如果没安装这个包，程序即使编译成功也不能运行，会提示找不到 winpcap.dll<br /><br />3、下载  <a href="http://www.winpcap.org/install/bin/WpdPack_4_0_1.zip">WinPcap Developer's 
						Packs</a><br />解压后会得一个目录WpdPack四个子目录：<br /> docs<br /> Examples-pcap<br /> Examples-remote<br /> Include<br /> Lib<br />然后配置VC++<br />tools --&gt; options  --&gt; Projects and Solutions  --&gt; VC++ Directories :<br /><ul><li><p>Include files ：<tt>WpdPackPath</tt><tt>\include</tt></p></li><li><p>Library files：<tt> WpdPackPath</tt><tt>\lib</tt></p></li></ul>其中 WpdPackPath是目录WpdPack的绝对路径<br /><br />4、新建一个 win32-&gt;win32 console application 工程，然后配置工程属性：<br /><ul><li>右键 -&gt; Properties -&gt; Configuration Properties -&gt; C/C++ -&gt; Preprocessor -&gt; Proprocessor Definition   往上面添加 WPCAP就可以了（这一步不做似乎也没什么问题~)</li><li>右键 -&gt; Properties -&gt; Configuration Properties -&gt; Linker -&gt; input -&gt; Additional Dependencies  往上面添加 wpcap.lib Packet.lib</li></ul>5、一个例子：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_145434" onclick="this.style.display='none'; Code_Closed_Text_145434.style.display='none'; Code_Open_Image_145434.style.display='inline'; Code_Open_Text_145434.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_145434" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_145434.style.display='none'; Code_Closed_Image_145434.style.display='inline'; Code_Closed_Text_145434.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_145434" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"></span><span id="Code_Open_Text_145434" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">#include </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">pcap.h</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br />#include </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">remote-ext.h</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> main()<br />{<br />    pcap_if_t </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">alldevs;<br />    pcap_if_t </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">d;<br />    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br />    </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);"> errbuf[PCAP_ERRBUF_SIZE];<br />    <br />    </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> Retrieve the device list from the local machine </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> auth is not needed </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">alldevs, errbuf) </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)<br />    {<br />        fprintf(stderr,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Error in pcap_findalldevs_ex: %s\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, errbuf);<br />        exit(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />    }<br />    <br />    </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> Print the list </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(d</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> alldevs; d </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> NULL; d</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> d</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">next)<br />    {<br />        printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d. %s</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">i, d</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">name);<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (d</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">description)<br />            printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> (%s)\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, d</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">description);<br />        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"><br />            printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> (No description available)\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (i </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)<br />    {<br />        printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\nNo interfaces found! Make sure WinPcap is installed.\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br />    }<br /><br />    </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> We don't need any more the device list. Free it </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    pcap_freealldevs(alldevs);<br /><br />    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br />}<br /></span></span></div>注意，如果不添加 #include "remote-ext.h" 也是会报错的~<br /><br />6、链接错误：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">anothertest.obj : error LNK2019: unresolved external symbol __imp__WSASetLastError@</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiGetNameInfo@</span><span style="color: rgb(0, 0, 0);">28</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__inet_ntoa@</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiLegacyGetAddrInfo@</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__htonl@</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiLegacyGetAddrInfo@</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__getservbyname@</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiLegacyGetAddrInfo@</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__htons@</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiLegacyGetAddrInfo@</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__inet_addr@</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiParseV4Address@</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__WSAGetLastError@</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiQueryDNS@</span><span style="color: rgb(0, 0, 0);">24</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__gethostbyname@</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiQueryDNS@</span><span style="color: rgb(0, 0, 0);">24</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__gethostbyaddr@</span><span style="color: rgb(0, 0, 0);">12</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiLegacyGetNameInfo@</span><span style="color: rgb(0, 0, 0);">28</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__getservbyport@</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiLegacyGetNameInfo@</span><span style="color: rgb(0, 0, 0);">28</span><span style="color: rgb(0, 0, 0);"><br />anothertest.obj : error LNK2019: unresolved external symbol __imp__ntohs@</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> referenced </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> function _WspiapiLegacyGetNameInfo@</span><span style="color: rgb(0, 0, 0);">28</span></div>解决该问题，需要只需把ws2_32.lib添加到wpcap.lib Packet.lib后面（见上面第4条）<img src ="http://www.blogjava.net/JafeLee/aggbug/148719.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-27 14:55 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/27/148719.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL命令 (9) -- 备份和恢复</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/21/146817.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Fri, 21 Sep 2007 13:47:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/21/146817.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/146817.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/21/146817.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/146817.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/146817.html</trackback:ping><description><![CDATA[1、备份整个数据库（估计也是最土的方法了）<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">mysqldump </span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">user=user --host=host --port=port </span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">password=password dbname &gt; filename.sql</span></div><ul><li>如果没有指定 host和port参数，则客户端会连向localhost的mysql server。</li><li>如果要备份多个数据库，则可添加参数 --database, 例如 --databases db1 db2</li><li>要备份数据库需要必要权限</li></ul>2、备份整个数据库相应的恢复方法：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">mysql </span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">user=user --host=host --port=port --password=password dbname &lt; filename.sql</span></div><br />（未完待续，尚在研究中~)<br /><img src ="http://www.blogjava.net/JafeLee/aggbug/146817.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-21 21:47 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/21/146817.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL命令 (8) -- 客服端命令行</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/21/146589.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Fri, 21 Sep 2007 13:46:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/21/146589.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/146589.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/21/146589.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/146589.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/146589.html</trackback:ping><description><![CDATA[1、连接到服务器：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">mysql </span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">-h host</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">-u user_name</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">-p</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">db_name]</span></div>注意：<br /><ul><li> db_name 表示默认数据库，相当与连接成功后的use db_name。</li><li>-p 表示密码选项，当有该选项是，mysql会弹出密码输入对话框，否则mysql将以匿名形式向服务器发送登录请求</li><li>也可以在-p后直接加上密码，mysql将直接向服务器发送登录请求，注意密码与-p之间不能有空格</li></ul>2、批量处理命令：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">echo </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">SELECT 1 + 1</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> mysql </span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">u some_user </span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">p</span></div>mysql命令行也支持重定向：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">mysql </span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">u </span><span style="color: rgb(255, 0, 255);">user</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">p </span><span style="color: rgb(128, 128, 128);">&lt;</span><span style="color: rgb(0, 0, 0);"> input_file </span><span style="color: rgb(128, 128, 128);">&gt;</span><span style="color: rgb(0, 0, 0);"> output_file</span></div><br />3、从执行文件执行命令（有两种方法）：<br />（1）<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">mysql </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">u <i>username</i> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">p <i>db_name</i> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> <i>file_name.sql</i></span></div>敲入该命令之后，会有一个密码输入的提示符，输入密码之后，会执行file_name.sql中的命令并打印这些命令返回的结果。<br />（2）首先从命令行连接连接数据库，在mysql的提示符下敲入：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">\. <i>file_name.sql</i></span></div>其中 \.表示从文件中执行命令， 文件名既可以包含绝对路径也可以包含相对路径<br /><br />4、如果要清除当前行的命令在命令后添加 \c，例如：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">DROP</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">DATABASE</span><span style="color: rgb(0, 0, 0);"> foo;\c</span></div>(未完待续，因不是很重要，暂不研究）<br /><img src ="http://www.blogjava.net/JafeLee/aggbug/146589.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-21 21:46 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/21/146589.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL命令 (7) -- 用户管理</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/19/146292.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Wed, 19 Sep 2007 11:19:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/19/146292.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/146292.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/19/146292.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/146292.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/146292.html</trackback:ping><description><![CDATA[1、创建一个新用户：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">CREATE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">USER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">user</span><span style="color: rgb(0, 128, 0);">@host</span><span style="color: rgb(0, 0, 0);"> IDENTIFIED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">password</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div>例如：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">CREATE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">USER</span><span style="color: rgb(0, 0, 0);"> test</span><span style="color: rgb(0, 128, 0);">@localhost</span><span style="color: rgb(0, 0, 0);"> IDENTIFIED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">localhost</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div>以及<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">CREATE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">USER</span><span style="color: rgb(0, 0, 0);"> test</span><span style="color: rgb(0, 128, 0);">@192</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">76.23</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">10</span><span style="color: rgb(0, 0, 0);"> IDENTIFIED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">remote</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div>上面两个例子创建的用户名名字虽然相同，但是两个的差别确实相当大的，例如，第一个test只能从本机登录，第二个test只能从ip为 192.76.23.10的机器登录。MySQL服务器通过两者的password来区别他们。<br /><br />2、删除一个用户：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">DROP</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">USER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">user</span><span style="color: rgb(0, 128, 0);">@host</span><span style="color: rgb(0, 0, 0);">;</span></div>如果没指明host，则默认为 drop user user@"%"，你必须在此前创建相应的用户，否则会引发错误。<br /><br />3、重命名一个用户：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">RENAME </span><span style="color: rgb(255, 0, 255);">USER</span><span style="color: rgb(0, 0, 0);"> old_user</span><span style="color: rgb(0, 128, 0);">@host</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">TO</span><span style="color: rgb(0, 0, 0);"> new_user</span><span style="color: rgb(0, 128, 0);">@host</span><span style="color: rgb(0, 0, 0);">;</span></div>实际上该命令既可以修改username，也可以修改host~<br /><br />4、使用通配符 % :<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">CREATE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">USER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">test</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">@</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">192.76.23.%</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">CREATE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">USER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">test</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">@</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">%</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div><br />5、获取有关用户和数据库关系的信息：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> Db </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> db <br /></span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">User</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">user</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">AND</span><span style="color: rgb(0, 0, 0);"> Host </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">host</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;<br /><br /><br /></span><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> Table_name </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> tables_priv<br /></span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">User</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">user</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">AND</span><span style="color: rgb(0, 0, 0);"> Host </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">host</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">AND</span><span style="color: rgb(0, 0, 0);"> Db </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">db</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;<br /></span></div>注意：表 db在数据库mysql中，该数据库还包括很多其他信息。<br /><br />6、设置密码：<br />设置自己的密码：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SET</span><span style="color: rgb(0, 0, 0);"> PASSWORD </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> PASSWORD(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">password</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);</span></div><br />设置别人的密码（必须有管理权限）：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SET</span><span style="color: rgb(0, 0, 0);"> PASSWORD </span><span style="color: rgb(0, 0, 255);">FOR</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">user</span><span style="color: rgb(0, 128, 0);">@host</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> PASSWORD(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">password</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);</span></div><br />7、赋予用户一定权限：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">GRANT</span><span style="color: rgb(0, 0, 0);"> </span><i><span style="color: rgb(0, 0, 255);">privileges</span><span style="color: rgb(0, 0, 0);"> </span></i><span style="color: rgb(0, 0, 255);">ON</span><span style="color: rgb(0, 0, 0);"> <i>db.</i></span><i><span style="color: rgb(0, 0, 255);">table</span></i><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">TO</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">user</span><span style="color: rgb(0, 128, 0);">@host</span><span style="color: rgb(0, 0, 0);"><br />IDENTIFIED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">password</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div>收回用户权限：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">REVOKE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">privileges</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">ON</span><span style="color: rgb(0, 0, 0);"> db.</span><span style="color: rgb(0, 0, 255);">table</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">user</span><span style="color: rgb(0, 128, 0);">@host</span><span style="color: rgb(0, 0, 0);"><br />IDENTIFIED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">password</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div><br /><img src ="http://www.blogjava.net/JafeLee/aggbug/146292.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-19 19:19 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/19/146292.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL命令 (6) -- 修改数据</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/18/146168.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Tue, 18 Sep 2007 10:31:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/18/146168.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/146168.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/18/146168.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/146168.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/146168.html</trackback:ping><description><![CDATA[1、update 基本用法：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">UPDATE</span><span style="color: rgb(0, 0, 0);"> book </span><span style="color: rgb(0, 0, 255);">SET</span><span style="color: rgb(0, 0, 0);"> cond </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">mint</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div>一般不要这么用，因为这会将一个column的所有行的cond设为 'mint'。<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">UPDATE</span><span style="color: rgb(0, 0, 0);"> book </span><span style="color: rgb(0, 0, 255);">SET</span><span style="color: rgb(0, 0, 0);"> author </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> "Theodor Geisel" </span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> author </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> "Dr. Seuss";<br /></span></div><br />2、在update中使用公式：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">UPDATE</span><span style="color: rgb(0, 0, 0);"> loan<br /></span><span style="color: rgb(0, 0, 255);">SET</span><span style="color: rgb(0, 0, 0);"> date_lent </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> DATE_ADD(date_lent, INTERVAL </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">YEAR</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> date_lent </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">2005-01-01</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;<br /></span></div><br />3、删除行：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">DELETE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> book </span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> cond </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">poor</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;</span></div>如果省略 where 语句，则会删除掉所有列<br /><br />4、从多个表中删除：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">DELETE</span><span style="color: rgb(0, 0, 0);"> book, loan    # tables </span><span style="color: rgb(0, 0, 255);">to</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">delete</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">from</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> book, loan    # tables </span><span style="color: rgb(0, 0, 255);">to</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">use</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">in</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> clause<br /></span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> book.book_id </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> loan.book_id<br /></span><span style="color: rgb(128, 128, 128);">AND</span><span style="color: rgb(0, 0, 0);"> book.cond </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">poor</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;<br /></span></div><br /><img src ="http://www.blogjava.net/JafeLee/aggbug/146168.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-18 18:31 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/18/146168.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MatLab运算符</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/15/145431.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Sat, 15 Sep 2007 14:44:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/15/145431.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/145431.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/15/145431.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/145431.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/145431.html</trackback:ping><description><![CDATA[（sigh，帮人做东西，不得不看MatLab了，是在不喜欢matlab，身不由己啊~）<br />1、算术运算符：<br /><div align="center"><img src="http://www.blogjava.net/images/blogjava_net/jafelee/mao.png" alt="mao.png" align="middle" border="0" height="468" width="255" /><br /></div><br />2、关系运算符<br /><div align="center"><img src="http://www.blogjava.net/images/blogjava_net/jafelee/matlabro.png" alt="matlabro.png" align="middle" border="0" height="212" width="223" /><br /></div><br />3、逻辑运算符<br /><div align="center"><img src="http://www.blogjava.net/images/blogjava_net/jafelee/matlablo.png" alt="matlablo.png" align="middle" border="0" height="209" width="729" /><br /></div><br /><img src ="http://www.blogjava.net/JafeLee/aggbug/145431.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-15 22:44 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/15/145431.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL命令 (5) -- 获取数据</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/14/145044.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Fri, 14 Sep 2007 02:45:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/14/145044.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/145044.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/14/145044.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/145044.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/145044.html</trackback:ping><description><![CDATA[1、限制返回的行数：<br />（1）<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> author </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> book LIMIT </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);">;</span></div>该命令将返回前两行记录<br />（2）<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> author </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> book LIMIT </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);">;</span></div>该命令返回两条记录，但是该记录是从第二条记录开始算起（注意,行数计数的起点是从0而不是1开始的，这跟Java中的数组很象)<br /><br />2、排序返回的结果：（order by)<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> name, birth </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> pet </span><span style="color: rgb(0, 0, 255);">ORDER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> birth;<br /></span></div><br />返回的序列以升序（默认）形式排列，如果想降序排列，则需要这样：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> name, birth </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> pet </span><span style="color: rgb(0, 0, 255);">ORDER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> birth </span><span style="color: rgb(0, 0, 255);">DESC</span><span style="color: rgb(0, 0, 0);">;<br /></span></div><br />你也可以显式指明按升序方式排列：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> name, birth </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> pet </span><span style="color: rgb(0, 0, 255);">ORDER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> birth </span><span style="color: rgb(0, 0, 255);">ASC</span><span style="color: rgb(0, 0, 0);">;<br /></span></div><br />DESC（ASC）也可以应用与多个column中：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> name, species, birth </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> pet </span><span style="color: rgb(0, 0, 255);">ORDER</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> species, birth </span><span style="color: rgb(0, 0, 255);">DESC</span><span style="color: rgb(0, 0, 0);">;<br /></span></div>结果：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">--------+---------+------------+</span><span style="color: rgb(0, 128, 128);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> name     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> species </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> birth      </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">--------+---------+------------+</span><span style="color: rgb(0, 128, 128);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Chirpy   </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> bird    </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1998</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">09</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">11</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Whistler </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> bird    </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1997</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">12</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">09</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Claws    </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> cat     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1994</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">03</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">17</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Fluffy   </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> cat     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1993</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">02</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">04</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|//------------------</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Fang     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> dog     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1990</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">08</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">27</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|//  降序排列</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Bowser   </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> dog     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1989</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">08</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">31</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|//  </span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Buffy    </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> dog     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1989</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">05</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">13</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|//</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Puffball </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> hamster </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1999</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">03</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">30</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|//-------------------</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> Slim     </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> snake   </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1996</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">04</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">29</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">--------+---------+------------+</span><span style="color: rgb(0, 128, 128);"><br /></span></div><br />3、去掉返回结果中相同的记录（只返回一个）：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">DISTINCT</span><span style="color: rgb(0, 0, 0);"> amount </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> loan;</span></div><br />4、模糊查询：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> name </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> author </span><span style="color: rgb(0, 0, 255);">WHERE</span><span style="color: rgb(0, 0, 0);"> name </span><span style="color: rgb(128, 128, 128);">LIKE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">M%</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;<br /></span></div>MySQL有两个通配符 % 和 _ 。其中 % 匹配 0或多个任意的字符， _ 匹配一个 任意字符<br /><br />5、获得某一行的最小值、最大值、平均值， 总和：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">MIN</span><span style="color: rgb(0, 0, 0);">(wt), </span><span style="color: rgb(255, 0, 255);">AVG</span><span style="color: rgb(0, 0, 0);">(wt), </span><span style="color: rgb(255, 0, 255);">MAX</span><span style="color: rgb(0, 0, 0);">(wt), </span><span style="color: rgb(255, 0, 255);">SUM</span><span style="color: rgb(0, 0, 0);">(wt) </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> person;<br /></span></div><br />6、时间运算：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> NOW(), CURTIME(), CURDATE();</span></div>运行结果：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">---------------------+-----------+------------+</span><span style="color: rgb(0, 128, 128);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> NOW()                      </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> CURTIME() </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> CURDATE()  </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">---------------------+-----------+------------+</span><span style="color: rgb(0, 128, 128);"><br /></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2007</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">09</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">14</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">10</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(128, 0, 0); font-weight: bold;">42</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(128, 0, 0); font-weight: bold;">20</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">10</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(128, 0, 0); font-weight: bold;">42</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(128, 0, 0); font-weight: bold;">20</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2007</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">09</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(128, 0, 0); font-weight: bold;">14</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">---------------------+-----------+------------+</span></div><br />7、把查询结果导出到文件：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">*</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> author<br />  </span><span style="color: rgb(0, 0, 255);">INTO</span><span style="color: rgb(0, 0, 0);"> OUTFILE </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">/tmp/author</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"><br />    FIELDS TERMINATED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">,</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"><br />    ENCLOSED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">"</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"><br />    LINES TERMINATED </span><span style="color: rgb(0, 0, 255);">BY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">\n</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;<br /></span></div><br />当用 into dumpfile 代替 into outfile时，select语句返回的结果必须不能多于1条。into dumpfile写入文件的格式既没有column分隔符，也没有行分隔符，这在将BLOB写入文件时很有用。<br /><img src ="http://www.blogjava.net/JafeLee/aggbug/145044.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-14 10:45 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/14/145044.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL命令 (4) -- 存储数据</title><link>http://www.blogjava.net/JafeLee/archive/2007/09/12/144458.html</link><dc:creator>Jafe Lee</dc:creator><author>Jafe Lee</author><pubDate>Wed, 12 Sep 2007 15:10:00 GMT</pubDate><guid>http://www.blogjava.net/JafeLee/archive/2007/09/12/144458.html</guid><wfw:comment>http://www.blogjava.net/JafeLee/comments/144458.html</wfw:comment><comments>http://www.blogjava.net/JafeLee/archive/2007/09/12/144458.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JafeLee/comments/commentRss/144458.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JafeLee/services/trackbacks/144458.html</trackback:ping><description><![CDATA[1、插入一条记录：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">INSERT</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">INTO</span><span style="color: rgb(0, 0, 0);"> table_name (list </span><span style="color: rgb(0, 0, 255);">of</span><span style="color: rgb(0, 0, 0);"> columns) </span><span style="color: rgb(0, 0, 255);">VALUES</span><span style="color: rgb(0, 0, 0);"> (list, </span><span style="color: rgb(0, 0, 255);">of</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 255);">values</span><span style="color: rgb(0, 0, 0);">);<br /></span></div><br />其中INTO似乎可以省略掉~<br /><br />2、一次插入多条记录：看下面的例子<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">INSERT</span><span style="color: rgb(0, 0, 0);"> book (author, title, cond) </span><span style="color: rgb(0, 0, 255);">VALUES</span><span style="color: rgb(0, 0, 0);"><br />    (</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">Maurice Sendak</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">In the Night Kitchen</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">mint</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">),<br />    (</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">Caroll Spinney</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">How to Be a Grouch</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">poor</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">),<br />    (</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">Dr. Seuss</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">Green Eggs and Ham</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">good</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);<br /></span></div><br />3、auto_increment属性：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">CREATE</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">TEMPORARY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">TABLE</span><span style="color: rgb(0, 0, 0);"> demo (<br />  id </span><span style="color: rgb(0, 0, 0); font-weight: bold;">INT</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">NOT</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">NULL</span><span style="color: rgb(0, 0, 0);"> AUTO_INCREMENT,<br />     </span><span style="color: rgb(0, 0, 255);">PRIMARY</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">KEY</span><span style="color: rgb(0, 0, 0);"> (id)<br />);<br /></span><span style="color: rgb(0, 0, 255);">INSERT</span><span style="color: rgb(0, 0, 0);"> demo () </span><span style="color: rgb(0, 0, 255);">VALUES</span><span style="color: rgb(0, 0, 0);"> ();<br /></span><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> id </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> demo; # id </span><span style="color: rgb(0, 0, 255);">contains</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">INSERT</span><span style="color: rgb(0, 0, 0);"> demo (id) </span><span style="color: rgb(0, 0, 255);">VALUES</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">NULL</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> id </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> demo; # id </span><span style="color: rgb(0, 0, 255);">contains</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">and</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">INSERT</span><span style="color: rgb(0, 0, 0);"> demo (id) </span><span style="color: rgb(0, 0, 255);">VALUES</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 0); font-weight: bold;">4</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> id </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> demo; # id </span><span style="color: rgb(0, 0, 255);">contains</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">and</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">4</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">INSERT</span><span style="color: rgb(0, 0, 0);"> demo (id) </span><span style="color: rgb(0, 0, 255);">VALUES</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">NULL</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 0, 255);">SELECT</span><span style="color: rgb(0, 0, 0);"> id </span><span style="color: rgb(0, 0, 255);">FROM</span><span style="color: rgb(0, 0, 0);"> demo; # id </span><span style="color: rgb(0, 0, 255);">contains</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(128, 0, 0); font-weight: bold;">4</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(128, 128, 128);"> and</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">5</span><span style="color: rgb(0, 0, 0);"><br /><br /></span></div>注意：一个表至多只能一个column是auto_increment的，而且该column必须是primary key的一个组成部分<br /><br /><br />4、插入当前日期和时间：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">INSERT some_table (some_column) VALUES (NOW());</span></div>运行<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">SELECT NOW();</span></div>可得到当前时间.<br /><br />5、从执行文件执行命令（有两种方法）：<br />（1）<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">mysql </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">u <i>username</i> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">p <i>db_name</i> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> <i>file_name.sql</i></span></div>敲入该命令之后，会有一个密码输入的提示符，输入密码之后，会执行file_name.sql中的命令并打印这些命令返回的结果。<br />（2）首先从命令行连接连接数据库，在mysql的提示符下敲入：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">\. <i>file_name.sql</i></span></div>其中 \.表示从文件中执行命令， 文件名既可以包含绝对路径也可以包含相对路径<br /><br />6、从另一个表复制数据：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">INSERT table_one (list, of, columns) SELECT <img src="http://www.blogjava.net/images/dot.gif" />;</span></div>注意：select 返回的column的类型和column的个数必须与insert的column和个数相兼容。<br /><br />7、从文件导入数据：<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">LOAD DATA INFILE </span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">some_file</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"> INTO TABLE <i>table_name</i></span><i><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"></span></i><span style="color: rgb(0, 0, 0);"> (list, of, columns, <img src="http://www.blogjava.net/images/dot.gif" />);<br /></span></div>需注意的几点：<br /><ul><li>LOAD DATA INFILE 有很多参数，具体可参照MySQL reference</li><li>数据文件必须和mysql server在同一台机器上，如果是远程机器，则必须在INFILE之前添加参数local<br /></li><li>文件名最好加上绝对路径，如果没有指明完整路径，则mysql server会在它的数据目录下寻找该文件，如果有local参数，则会在你启动客服端的目录下找</li><li>在windows下，路径的标识符不能用反斜杠 \ ,只能使用正斜杠 / 或者使用转义字符 \\</li><li>使用小技巧：可以用show errors; 或show warnings;命令来查看返回的具体的错误信息。在将数据导入到table之前，可以先建立一个和要导入的表的结构一样temporary table(使用create table  ...like 命令，把数据导入到该临时表中看看结果是否正确</li></ul>8、存储精确的浮点数：使用DECIMAL类型，该类型在MySQL中是一字符串的形式存储的。<br /><img src ="http://www.blogjava.net/JafeLee/aggbug/144458.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JafeLee/" target="_blank">Jafe Lee</a> 2007-09-12 23:10 <a href="http://www.blogjava.net/JafeLee/archive/2007/09/12/144458.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>