﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>奋斗足迹&#124;崔玉松 &#187; Database</title>
	<atom:link href="http://fendou.org/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://fendou.org</link>
	<description>为家人，为自己，为生活~~</description>
	<lastBuildDate>Fri, 24 Feb 2012 15:21:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Mysql中union和order by的问题及优先级</title>
		<link>http://fendou.org/2011/11/16/mysql-union-order-by-problem/</link>
		<comments>http://fendou.org/2011/11/16/mysql-union-order-by-problem/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 07:03:10 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Excellence Article]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=854</guid>
		<description><![CDATA[在Mysql的参考手册中，并没有对union和order by的优先级进行说明 它建议的方法是，对SQL语句加上（），这样能使SQL的语义更清晰 例如，需要对union后的结果进行order by，则： &#40;SELECT a FROM tbl_name WHERE a=10 AND B=1&#41; UNION &#40;SELECT a FROM tbl_name WHERE a=11 AND B=2&#41; ORDER BY a LIMIT 10； 如果，需要对单个SQL语句进行order by，则应把order by子句放入圆括号中，如下： &#40;SELECT a FROM tbl_name WHERE a=10 AND B=1 ORDER BY a LIMIT 10&#41; UNION &#40;SELECT a FROM tbl_name WHERE a=11 AND B=2 ORDER BY a...  <a href="http://fendou.org/2011/11/16/mysql-union-order-by-problem/" class="more-link" title="Read Mysql中union和order by的问题及优先级">Read more &#187;</a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F02%2F26%2Fmysql-trigger-one%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL触发器介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql存储过程学习笔记--变量、参数、注释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p> 在Mysql的参考手册中，并没有对union和order by的优先级进行说明<br />
它建议的方法是，对SQL语句加上（），这样能使SQL的语义更清晰<br />
例如，需要对union后的结果进行order by，则：</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> a <span style="color: #993333; font-weight: bold;">FROM</span> tbl_name <span style="color: #993333; font-weight: bold;">WHERE</span> a<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">10</span> <span style="color: #993333; font-weight: bold;">AND</span> B<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>  
<span style="color: #993333; font-weight: bold;">UNION</span>  
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> a <span style="color: #993333; font-weight: bold;">FROM</span> tbl_name <span style="color: #993333; font-weight: bold;">WHERE</span> a<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">11</span> <span style="color: #993333; font-weight: bold;">AND</span> B<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>  
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> a <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">10</span>；</pre></div></div>

<p>如果，需要对单个SQL语句进行order by，则应把order by子句放入圆括号中，如下：</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> a <span style="color: #993333; font-weight: bold;">FROM</span> tbl_name <span style="color: #993333; font-weight: bold;">WHERE</span> a<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">10</span> <span style="color: #993333; font-weight: bold;">AND</span> B<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> a <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>  
<span style="color: #993333; font-weight: bold;">UNION</span>  
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> a <span style="color: #993333; font-weight: bold;">FROM</span> tbl_name <span style="color: #993333; font-weight: bold;">WHERE</span> a<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">11</span> <span style="color: #993333; font-weight: bold;">AND</span> B<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">2</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> a <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>另外注意：圆括号中用于单个SQL语句的ORDER BY只有当与LIMIT结合后，才起作用。否则，ORDER BY被优化去除。<br />
我在innodb引擎的2个表上测试了没有加()，进行union和order by的操作，如下：</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> a <span style="color: #993333; font-weight: bold;">FROM</span> tbl_name <span style="color: #993333; font-weight: bold;">WHERE</span> a<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">10</span> <span style="color: #993333; font-weight: bold;">AND</span> B<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>  
<span style="color: #993333; font-weight: bold;">UNION</span>  
<span style="color: #993333; font-weight: bold;">SELECT</span> a <span style="color: #993333; font-weight: bold;">FROM</span> tbl_name <span style="color: #993333; font-weight: bold;">WHERE</span> a<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">11</span> <span style="color: #993333; font-weight: bold;">AND</span> B<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">2</span>  
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> a <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">10</span>;</pre></div></div>

<p>发现，它默认的结果也是先进行union，然后再order by，和第一种情况执行结果相同<br />
不过，为了逻辑清晰，最好还是加上对应的()比较好<br />
另外：Mysql中union可以有union，union distinct，union all这3中形式<br />
union和union distinct会对union后的结果进行排重，保证所有返回的行都是唯一的<br />
union all则会返回所有SELECT语句中得到所有匹配的行</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F02%2F26%2Fmysql-trigger-one%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL触发器介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql存储过程学习笔记--变量、参数、注释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2011/11/16/mysql-union-order-by-problem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL通信协议</title>
		<link>http://fendou.org/2011/05/06/mysql-communication-protocols/</link>
		<comments>http://fendou.org/2011/05/06/mysql-communication-protocols/#comments</comments>
		<pubDate>Fri, 06 May 2011 15:26:40 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=825</guid>
		<description><![CDATA[MySQL实现了四种通信协议 TCP/IP协议，通常我们通过来连接MySQL，各种主要编程语言都是根据这个协议实现了连接模块 Unix Socket协议，这个通常我们登入MySQL服务器中使用这个协议，因为要使用这个协议连接MySQL需要一个物理文件，文件的存放位置在配置文件中有定义，值得一提的是，这是所有协议中最高效的一个。 Share Memory协议，这个协议一般人不知道，肯定也没用过，因为这个只有windows可以使用，使用这个协议需要在配置文件中在启动的时候使用&#8211;shared-memory参数，注意的是，使用此协议，一个host上只能有一个server，所以这个东西一般没啥用的，除非你怀疑其他协议不能正常工作，实际上微软的SQL Sever也支持这个协议 Named Pipes协议，这个协议也是只有windows才可以用，同shared memory一样，使用此协议，一个host上依然只能有一个server，即使是使用不同的端口也不行，Named Pipes 是为局域网而开发的协议。内存的一部分被某个进程用来向另一个进程传递信息，因此一个进程的输出就是另一个进程的输入。第二个进程可以是本地的（与第一个进程位于同一台计算机上），也可以是远程的（位于联网的计算机上）。正因为如此，假如你的环境中没有或者禁用TCP/IP环境，而且是windows服务器，那么好歹你的数据库还能工作。使用这个协议需要在启动的时候添加&#8211;enable-named-pipe选项 Named Pipes和Shared Memory协议都非常的低效，而且只能用于windows环境，非必要情况尽量避免使用<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql存储过程学习笔记--变量、参数、注释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql中union和order by的问题及优先级</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>MySQL实现了四种通信协议</p>
<ol>
<li>TCP/IP协议，通常我们通过来连接MySQL，各种主要编程语言都是根据这个协议实现了连接模块</li>
<li>Unix Socket协议，这个通常我们登入MySQL服务器中使用这个协议，因为要使用这个协议连接MySQL需要一个物理文件，文件的存放位置在配置文件中有定义，值得一提的是，这是所有协议中最高效的一个。</li>
<li>Share Memory协议，这个协议一般人不知道，肯定也没用过，因为这个只有windows可以使用，使用这个协议需要在配置文件中在启动的时候使用&#8211;shared-memory参数，注意的是，使用此协议，一个host上只能有一个server，所以这个东西一般没啥用的，除非你怀疑其他协议不能正常工作，实际上微软的SQL Sever也支持这个协议</li>
<li>Named Pipes协议，这个协议也是只有windows才可以用，同shared memory一样，使用此协议，一个host上依然只能有一个server，即使是使用不同的端口也不行，Named Pipes 是为局域网而开发的协议。内存的一部分被某个进程用来向另一个进程传递信息，因此一个进程的输出就是另一个进程的输入。第二个进程可以是本地的（与第一个进程位于同一台计算机上），也可以是远程的（位于联网的计算机上）。正因为如此，假如你的环境中没有或者禁用TCP/IP环境，而且是windows服务器，那么好歹你的数据库还能工作。使用这个协议需要在启动的时候添加&#8211;enable-named-pipe选项</li>
</ol>
<p><span style="font-size: small;"><span style="line-height: 24px;"><span style="color: #ff0000;">Named Pipes和Shared Memory协议都非常的低效，而且只能用于windows环境，非必要情况尽量避免使用</span><br />
</span></span></p>
<p><span style="font-size: small;"><span style="line-height: 24px;"><br />
</span></span></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql存储过程学习笔记--变量、参数、注释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F11%2F16%2Fmysql-union-order-by-problem%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql中union和order by的问题及优先级</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2011/05/06/mysql-communication-protocols/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL 5.1.56 使用 InnoDB Plugin</title>
		<link>http://fendou.org/2011/05/06/mysql-5-1-56-innodb-plugin/</link>
		<comments>http://fendou.org/2011/05/06/mysql-5-1-56-innodb-plugin/#comments</comments>
		<pubDate>Fri, 06 May 2011 12:58:30 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=821</guid>
		<description><![CDATA[[root@localhost mysql-5.1.56]# ./configure --prefix=/usr/local/mysql/ \ --without-debug \ --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \ --with-client-ldflags=-all-static \ --with-mysqld-ldflags=-all-static \ --enable-assembler \ --with-charset=utf8 \ --with-collation=utf8_general_ci \ --with-extra-charsets=latin1,gb2312 \ --with-pthread --enable-thread-safe-client \ --with-plugins=myisam,innodb_plugin<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F02%2F26%2Fmysql-trigger-one%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL触发器介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">[root@localhost mysql-5.1.56]# ./configure --prefix=/usr/local/mysql/ \
--without-debug \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--enable-assembler  \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--with-extra-charsets=latin1,gb2312 \
--with-pthread --enable-thread-safe-client   \
--with-plugins=myisam,innodb_plugin</pre></div></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F02%2F26%2Fmysql-trigger-one%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL触发器介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-5-1-56-innodb-plugin%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2011/05/06/mysql-5-1-56-innodb-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP中操作mysql执行存储过程</title>
		<link>http://fendou.org/2010/05/28/php-mysql-procedure/</link>
		<comments>http://fendou.org/2010/05/28/php-mysql-procedure/#comments</comments>
		<pubDate>Fri, 28 May 2010 15:01:14 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=696</guid>
		<description><![CDATA[存储过程和函数是MySql5.0中引入的。关于这方面的操作在PHP里面没有直接的支持。但是由于Mysql PHP API的设计，使得我们可以在以前的PHP版本中的mysql php api中支持存储过程和函数的调用。 在php中调用存储过程和函数。 1.调用存储过程的方法。 a. 如果存储过程有 IN/INOUT参数，声明一个变量，输入参数给存储过程，该变量是一对， 一个php变量（也可以不必，只是没有php变量时，没有办法进行动态输入），一个Mysql变量。 b.如果存储过程有OUT变量，声明一个Mysql变量。mysql变量的声明比较特殊，必须让mysql服务器知道此变量的存在，其实也就是执行一条mysql语句。 如 set @mysqlvar=$phpvar ; c.使用mysql_query()/mysql_db_query()执行mysql 变量声明语句。 mysql_query(“set @mysqlvar [=$pbpvar]“); 这样，在mysql服务器里面就有一个变量，@mysqlar。如果时IN参数，那么其值可以有phpar传入。 d. 如果是存储过程。 1. 执行 call procedure（）语句。 也就是mysql_query(“call proceduer([var1]&#8230;)”); 2. 如果有返回值，执行select @ar，返回执行结果。 mysql_query(“select @var)” 接下来的操作就和php执行一般的mysql语句一样了。可以通过mydql_fetch_row()等函数获得结果。 如果时函数。 直接执行 select function（） 就可以了。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>存储过程和函数是MySql5.0中引入的。关于这方面的操作在PHP里面没有直接的支持。但是由于Mysql PHP API的设计，使得我们可以在以前的PHP版本中的mysql php api中支持存储过程和函数的调用。</p>
<p>在php中调用存储过程和函数。</p>
<p>1.调用存储过程的方法。</p>
<p>a. 如果存储过程有 IN/INOUT参数，声明一个变量，输入参数给存储过程，该变量是一对， 一个php变量（也可以不必，只是没有php变量时，没有办法进行动态输入），一个Mysql变量。<br />
b.如果存储过程有OUT变量，声明一个Mysql变量。mysql变量的声明比较特殊，必须让mysql服务器知道此变量的存在，其实也就是执行一条mysql语句。<br />
     如  set @mysqlvar=$phpvar ;<br />
 c.使用mysql_query()/mysql_db_query()执行mysql 变量声明语句。<br />
mysql_query(“set @mysqlvar [=$pbpvar]“);<br />
这样，在mysql服务器里面就有一个变量，@mysqlar。如果时IN参数，那么其值可以有phpar传入。</p>
<p>d. 如果是存储过程。<br />
1. 执行 call procedure（）语句。<br />
      也就是mysql_query(“call proceduer([var1]&#8230;)”);<br />
2. 如果有返回值，执行select  @ar，返回执行结果。<br />
 mysql_query(“select @var)”<br />
 接下来的操作就和php执行一般的mysql语句一样了。可以通过mydql_fetch_row()等函数获得结果。<br />
如果时函数。 直接执行 select function（） 就可以了。</p>
<pre lang=''php">
$host="localhost";
    $user="root";
    $passWord="11212";
    $db="samp_db";
    $dblink=mysql_connect($host,$user,$password)
            or die("can't connect to mysql");
mysql_select_db($db,$dblink)
      or die("can't select samp_db");
    $res=mysql_query("set @a=$password",$dblink);
    $res=mysql_query("call aa(@a)",$dblink);
    $res=mysql_query("select @a",$dblink);
    $row=mysql_fetch_row($res);
    echo $row[0];
</pre>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/05/28/php-mysql-procedure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mysql存储过程学习笔记&#8211;变量、参数、注释</title>
		<link>http://fendou.org/2010/05/28/mysql-variable-params-comment/</link>
		<comments>http://fendou.org/2010/05/28/mysql-variable-params-comment/#comments</comments>
		<pubDate>Fri, 28 May 2010 14:50:37 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=694</guid>
		<description><![CDATA[变量定义: DECLARE variable_name [,variable_name...] datatype [DEFAULT value]; 其中，datatype为mysql的数据类型，如:INT, FLOAT, DATE, VARCHAR(length) 例: DECLARE l_int INT unsigned default 4000000; DECLARE l_numeric NUMERIC(8,2) DEFAULT 9.95; DECLARE l_date DATE DEFAULT &#8217;1999-12-31&#8242;; DECLARE l_datetime DATETIME DEFAULT &#8217;1999-12-31 23:59:59&#8242;; DECLARE l_varchar VARCHAR(255) DEFAULT &#8216;This will not be padded&#8217;;   变量赋值 SET 变量名 = 表达式值 [,variable_name = expression ...] 参数 mysql存储过程的参数用在存储过程的定义，共有三种参数类型,IN,OUT,INOUT Create...  <a href="http://fendou.org/2010/05/28/mysql-variable-params-comment/" class="more-link" title="Read Mysql存储过程学习笔记&#8211;变量、参数、注释">Read more &#187;</a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql root帐号丢失解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p style="font: normal normal normal 12px/normal song, Verdana;"><strong><span style="text-decoration: underline;">变量定义:</span></strong></p>
<table style="font-size: 12px; width: 494px; border: 1px solid #999999;" border="0" align="center">
<tbody>
<tr style="font: normal normal normal 12px/normal song, Verdana;">
<td style="font: normal normal normal 12px/normal song, Verdana;">DECLARE variable_name [,variable_name...] datatype [DEFAULT value];</td>
</tr>
</tbody>
</table>
<p style="font: normal normal normal 12px/normal song, Verdana;">其中，datatype为mysql的数据类型，如:INT, FLOAT, DATE, VARCHAR(length)</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">例:</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">DECLARE l_int INT unsigned default 4000000; DECLARE l_numeric NUMERIC(8,2) DEFAULT 9.95; DECLARE l_date DATE DEFAULT &#8217;1999-12-31&#8242;; DECLARE l_datetime DATETIME DEFAULT &#8217;1999-12-31 23:59:59&#8242;; DECLARE l_varchar VARCHAR(255) DEFAULT &#8216;This will not be padded&#8217;;  <br style="font: normal normal normal 12px/normal song, Verdana;" /></p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong><span style="text-decoration: underline;">变量赋值</span></strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">SET 变量名 = 表达式值 [,variable_name = expression ...]<br style="font: normal normal normal 12px/normal song, Verdana;" /></p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><span style="text-decoration: underline;"><strong>参数</strong></span></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql存储过程的参数用在存储过程的定义，共有三种参数类型,IN,OUT,INOUT</p>
<table style="font-size: 12px; width: 494px; border: 1px solid #999999;" border="0" align="center">
<tbody>
<tr style="font: normal normal normal 12px/normal song, Verdana;">
<td style="font: normal normal normal 12px/normal song, Verdana;">Create procedure|function([[IN |OUT |INOUT ] 参数名 数据类形&#8230;])</td>
</tr>
</tbody>
</table>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong>IN 输入参数</strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">表示该参数的值必须在调用存储过程时指定，在存储过程中修改该参数的值不能被返回，为默认值</p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong>OUT 输出参数</strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">该值可在存储过程内部被改变，并可返回</p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong>INOUT 输入输出参数</strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">调用时指定，并且可被改变和返回</p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong>IN参数例子:</strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">创建</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql&gt; CREATE PROCEDURE sp_demo_in_parameter(IN p_in INT) BEGIN SELECT p_in; /*查询输入参数*/*/ SET p_in=2; /*修改*/ select p_in;/*查看修改后的值*/ END; <br style="font: normal normal normal 12px/normal song, Verdana;" />执行结果:<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; set @p_in=1<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; call sp_demo_in_parameter(@p_in)<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| p_in |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />|    1 | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| p_in |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />|    2 | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; select @p_in;<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| @p_in |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| 1     |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" /></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">以上可以看出，p_in虽然在存储过程中被修改，但并不影响@p_id的值</p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong>OUT参数例子</strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">创建:</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql&gt; CREATE PROCEDURE sp_demo_out_parameter(OUT p_out INT) BEGIN SELECT p_out;/*查看输出参数*/ SET p_out=2;/*修改参数值*/ SELECT p_out;/*看看有否变化*/ END; <br style="font: normal normal normal 12px/normal song, Verdana;" />执行结果:<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; SET @p_out=1<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; CALL sp_demo_out_parameter(@p_out)<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| p_out | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />|  NULL | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />/*未被定义，返回NULL*/<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| p_out |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />|     2 | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; SELECT @p_out;<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| p_out |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />|     2 | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;-+</p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong>INOUT参数例子:</strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql&gt; CREATE PROCEDURE sp_demo_inout_parameter(INOUT p_inout INT) BEGIN SELECT p_inout; SET p_inout=2; SELECT p_inout; END; <br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />执行结果:<br style="font: normal normal normal 12px/normal song, Verdana;" />set @p_inout=1<br style="font: normal normal normal 12px/normal song, Verdana;" />call sp_demo_inout_parameter(@p_inout) //<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| p_inout |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />|       1 |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| p_inout | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />|       2 |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />select @p_inout;<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| @p_inout | <br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| 2        |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" /></p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong><span style="text-decoration: underline;">用户变量</span></strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">1、  在mysql客户端使用用户变量</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql&gt; SELECT &#8216;Hello World&#8217; into @x;<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; SELECT @x;<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| @x          |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| Hello World |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; SET @y=&#8217;Goodbye Cruel World&#8217;;<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; select @y;<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| @y                  |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| Goodbye Cruel World |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; SET @z=1+2+3;<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; select @z;<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| @z   |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| 6    |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;+<br style="font: normal normal normal 12px/normal song, Verdana;" /></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">2、  在存储过程中使用用户变量</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql&gt; CREATE PROCEDURE GreetWorld(  )  SELECT CONCAT(@greeting,&#8217; World&#8217;);<br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; SET @greeting=&#8217;Hello&#8217;;<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; CALL GreetWorld(  );<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| CONCAT(@greeting,&#8217; World&#8217;) |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" />| Hello World                |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br style="font: normal normal normal 12px/normal song, Verdana;" /></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">3、  在存储过程间传递全局范围的用户变量</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql&gt; CREATE PROCEDURE p1(  )   SET @last_procedure=&#8217;p1&#8242;;<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; CREATE PROCEDURE p2(  )  SELECT CONCAT(&#8216;Last procedure was &#8216;,@last_procedure);<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; CALL p1(  );<br style="font: normal normal normal 12px/normal song, Verdana;" /> <br style="font: normal normal normal 12px/normal song, Verdana;" />mysql&gt; CALL p2(  );<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| CONCAT(&#8216;Last procedure was &#8216;,@last_procedure) |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br style="font: normal normal normal 12px/normal song, Verdana;" />| Last procedure was p1                         |<br style="font: normal normal normal 12px/normal song, Verdana;" />+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br style="font: normal normal normal 12px/normal song, Verdana;" /></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">注意:</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">①用户变量名一般以@开头</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">②滥用用户变量会导致程序难以理解及管理</p>
<p style="font: normal normal normal 12px/normal song, Verdana;"><strong><span style="text-decoration: underline;">注释</span></strong></p>
<p style="font: normal normal normal 12px/normal song, Verdana;">mysql存储过程可使用两种风格的注释</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">双模杠：&#8211;</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">该风格一般用于单行注释</p>
<p style="font: normal normal normal 12px/normal song, Verdana;">c风格：/* 注释内容 */ 一般用于多行注释</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql root帐号丢失解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/05/28/mysql-variable-params-comment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>数据库管理系统基本组件及运行流程图</title>
		<link>http://fendou.org/2010/05/07/database-management-system-compoment/</link>
		<comments>http://fendou.org/2010/05/07/database-management-system-compoment/#comments</comments>
		<pubDate>Fri, 07 May 2010 02:41:48 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=685</guid>
		<description><![CDATA[一图胜千言，图片出自《Database Management System 》一书,斯坦福大学可以查到这本书的PDF<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">数据库的层次结构</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F07%2F22%2Fsome-books-part-one%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对我影响最大的基本技术书（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F04%2F11%2Flinux-network-manage-tools%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Linux网络管理中的几个小工具</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F12%2Fphp%25E4%25B8%258A%25E4%25BC%25A0%25E3%2580%2581%25E7%25AE%25A1%25E7%2590%2586%25E7%2585%25A7%25E7%2589%2587%25E7%25A4%25BA%25E4%25BE%258B%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">php上传、管理照片示例</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F12%2F02%2Fhow-to-be-a-good-manager-from-a-developer%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">《从技术走向管理》</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>一图胜千言，图片出自《Database Management System 》一书,<a href="http://infolab.stanford.edu/~ullman/fcdb/ch1.pdf" target="_blank">斯坦福大学可以查到这本书</a>的PDF</p>
<p style="text-align: center;"><a href="http://pic.yupoo.com/cuimuxi/927319483c18/py8uogki.jpg"><img class=" aligncenter" title="database_management_system_compoment" src="http://pic.yupoo.com/cuimuxi/927319483c18/py8uogki.jpg" alt="database_management_system_compoment" /></a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">数据库的层次结构</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F07%2F22%2Fsome-books-part-one%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对我影响最大的基本技术书（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F04%2F11%2Flinux-network-manage-tools%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Linux网络管理中的几个小工具</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2007%2F11%2F12%2Fphp%25E4%25B8%258A%25E4%25BC%25A0%25E3%2580%2581%25E7%25AE%25A1%25E7%2590%2586%25E7%2585%25A7%25E7%2589%2587%25E7%25A4%25BA%25E4%25BE%258B%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">php上传、管理照片示例</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F12%2F02%2Fhow-to-be-a-good-manager-from-a-developer%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F05%2F07%2Fdatabase-management-system-compoment%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">《从技术走向管理》</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/05/07/database-management-system-compoment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>数据库的层次结构</title>
		<link>http://fendou.org/2010/03/15/database-hierarchy-structures/</link>
		<comments>http://fendou.org/2010/03/15/database-hierarchy-structures/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 14:01:39 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[读书笔记]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=667</guid>
		<description><![CDATA[1、树状结构 在历史上，层次数据库最早出现，将数据库保存为文件中的记录，各种逻辑被嵌套到一起，而没有将同样的记录按照线性排列。层次数据库对某些查询非常适合，但是过强的结构限制了人们对数据的自由操控，后来出现的网络（CODASYL）数据库，虽然灵活了很多，但数据操控仍然很困难，知道关系型理论的出现，才证明的了数据库设计是科学而不是工艺，然而，因为层次模型很有弹性，所以层次结构依然极为常见（至少层次描述非常常见），例如XML和LDAP等层次技术非常活跃，严格的说HTML也算是一种层次存取数据的方式。 层次式数据不太容易理解，比如ERP系统中最基本的物料单，层次结构之所以复杂，主要原因不是因为组件之间的关系表达，而是访问树的方式，我们访问树的部分或全部节点，通常按照顺序返回这些节点，访问树通常由DBMS引擎以过程性方式实现，而过程性操作正是违背关系理论的主要表现之一。 2、树状结构和主从结构 很多人认为“父子关系”和“主从关系”没有什么不同，实际上这两种关系有着很多的不同。 1） 树状结构保存只需要一个表。代表层次结构的树，其所有节点完全相同，叶子节点的类型有时可能不同，例如文件系统中的文件夹和文件节点，如果撇去这点，所有的节点类型完全相同，我们可以用相同的方法描述，而且同一个表来代表节点，换句话说，表与它本身之间有种主从关系，而不是两个类型不同的表关系。 2）深度。层次结构中，与根节点的距离本身是重要的信息，而在主从关系中，不是主表就是明细表。 3）所有权。主从关系中，可以明确的外键完整性约束，例如，每个表中订单必须与另外一张表的已存在的ID对应，但层次结构，比如，虽然比如经理的工号虽然是参照已经存在的员工的工号规则来的，但是经理向老板报告，不跟员工报告，这会导致NULL值问题。 4）多重父节点。以父节点似乎别数据结合子节点，是假设一个子节点只有一个父节点，实际上生活中，很多情况下都不是这样，比如机械零件和螺丝钉，那就不是树了，父子关系就无能为力了。 其实某位大牛曾经说过：从关系理论角度去理解树的结构，树有两种实体类型，一个是节点，另一个是节点之间的连接。这样的设计世界上是解决了完整性约束的的问题，因为只有实际存在连结的节点才能被描述。这种描述实际上最后能描出一个图来，也就是能解决一个子节点对应多个父节点的问题。 DBMS厂商常常实现了空间数据处理或全文索引等特殊功能，但对层次结构的支持很薄弱或者根本没有。 处理层次结构的主要困难在于树的访问，当然仅仅为了在图形用户界面中显示树状结构，每次用户点击将树展开并没有什么问题<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql存储过程学习笔记--变量、参数、注释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>1、树状结构<br />
在历史上，层次数据库最早出现，将数据库保存为文件中的记录，各种逻辑被嵌套到一起，而没有将同样的记录按照线性排列。层次数据库对某些查询非常适合，但是过强的结构限制了人们对数据的自由操控，后来出现的网络（CODASYL）数据库，虽然灵活了很多，但数据操控仍然很困难，知道关系型理论的出现，才证明的了数据库设计是科学而不是工艺，然而，因为层次模型很有弹性，所以层次结构依然极为常见（至少层次描述非常常见），例如XML和LDAP等层次技术非常活跃，严格的说HTML也算是一种层次存取数据的方式。<br />
层次式数据不太容易理解，比如ERP系统中最基本的物料单，层次结构之所以复杂，主要原因不是因为组件之间的关系表达，而是访问树的方式，我们访问树的部分或全部节点，通常按照顺序返回这些节点，访问树通常由DBMS引擎以过程性方式实现，而过程性操作正是违背关系理论的主要表现之一。<br />
2、树状结构和主从结构<br />
很多人认为“父子关系”和“主从关系”没有什么不同，实际上这两种关系有着很多的不同。<br />
 1） 树状结构保存只需要一个表。代表层次结构的树，其所有节点完全相同，叶子节点的类型有时可能不同，例如文件系统中的文件夹和文件节点，如果撇去这点，所有的节点类型完全相同，我们可以用相同的方法描述，而且同一个表来代表节点，换句话说，表与它本身之间有种主从关系，而不是两个类型不同的表关系。<br />
2）深度。层次结构中，与根节点的距离本身是重要的信息，而在主从关系中，不是主表就是明细表。<br />
3）所有权。主从关系中，可以明确的外键完整性约束，例如，每个表中订单必须与另外一张表的已存在的ID对应，但层次结构，比如，虽然比如经理的工号虽然是参照已经存在的员工的工号规则来的，但是经理向老板报告，不跟员工报告，这会导致NULL值问题。<br />
4）多重父节点。以父节点似乎别数据结合子节点，是假设一个子节点只有一个父节点，实际上生活中，很多情况下都不是这样，比如机械零件和螺丝钉，那就不是树了，父子关系就无能为力了。<br />
其实某位大牛曾经说过：从关系理论角度去理解树的结构，树有两种实体类型，一个是节点，另一个是节点之间的连接。这样的设计世界上是解决了完整性约束的的问题，因为只有实际存在连结的节点才能被描述。这种描述实际上最后能描出一个图来，也就是能解决一个子节点对应多个父节点的问题。<br />
DBMS厂商常常实现了空间数据处理或全文索引等特殊功能，但对层次结构的支持很薄弱或者根本没有。<br />
处理层次结构的主要困难在于树的访问，当然仅仅为了在图形用户界面中显示树状结构，每次用户点击将树展开并没有什么问题 <img src='http://fendou.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fmysql-variable-params-comment%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Mysql存储过程学习笔记--变量、参数、注释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F15%2Fdatabase-hierarchy-structures%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/03/15/database-hierarchy-structures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql root帐号丢失解决办法</title>
		<link>http://fendou.org/2010/03/07/mysql-root-lose/</link>
		<comments>http://fendou.org/2010/03/07/mysql-root-lose/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 00:15:58 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=665</guid>
		<description><![CDATA[一.windows系统的解决方法 1.首先以系统管理员身份登陆系统。 2.停止MySQL的服务。 3.进入命令窗口，然后进入MySQL的安装目录，比如我的安装目录是c:\mysql,进入C:\mysql\bin 4.跳过权限检查启动MySQL，c:\mysql\bin>;mysqld-nt &#8211;skip-grant-tables (或者将&#8211;skip-grant-tables写入my.ini中，重新启动Mysql，即可设置新密码)。 5.重新打开一个窗口，进入c:\mysql\bin目录，设置root的新密码 c:\mysql\bin>mysqladmin -u root flush-privileges password “newpassword” c:\mysql\bin>mysqladmin -u root -p shutdown 将newpassword替换为你要用的root的密码，第二个命令会提示你输入新密码，重复第一个命令输入的密码。 6.停止MySQL Server，用正常模式启动Mysql 7．你可以用新的密码链接到Mysql了。 二.Unix/Linux的解决方法 1.用root或者运行mysqld的用户登录系统； 2．利用kill命令结束掉mysqld的进程； 3．使用&#8211;skip-grant-tables参数启动MySQL Server shell>mysqld_safe &#8211;skip-grant-tables &#038; 4.为root@localhost设置新密码 shell>mysqladmin -u root flush-privileges password “newpassword” 5．重启MySQL Server<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>一.windows系统的解决方法<br />
1.首先以系统管理员身份登陆系统。<br />
2.停止MySQL的服务。<br />
3.进入命令窗口，然后进入MySQL的安装目录，比如我的安装目录是c:\mysql,进入C:\mysql\bin<br />
4.跳过权限检查启动MySQL，c:\mysql\bin>;mysqld-nt &#8211;skip-grant-tables<br />
(或者将&#8211;skip-grant-tables写入my.ini中，重新启动Mysql，即可设置新密码)。<br />
5.重新打开一个窗口，进入c:\mysql\bin目录，设置root的新密码<br />
c:\mysql\bin>mysqladmin -u root flush-privileges password “newpassword”<br />
c:\mysql\bin>mysqladmin -u root -p shutdown<br />
将newpassword替换为你要用的root的密码，第二个命令会提示你输入新密码，重复第一个命令输入的密码。<br />
6.停止MySQL Server，用正常模式启动Mysql<br />
7．你可以用新的密码链接到Mysql了。</p>
<p>二.Unix/Linux的解决方法<br />
1.用root或者运行mysqld的用户登录系统；<br />
2．利用kill命令结束掉mysqld的进程；<br />
3．使用&#8211;skip-grant-tables参数启动MySQL Server<br />
shell>mysqld_safe &#8211;skip-grant-tables &#038;<br />
4.为root@localhost设置新密码<br />
shell>mysqladmin -u root flush-privileges password “newpassword”<br />
5．重启MySQL Server</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F07%2F05%2Fmysql-index-limit%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL中索引限制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-root-lose%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/03/07/mysql-root-lose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL视图介绍</title>
		<link>http://fendou.org/2010/03/07/mysql-view/</link>
		<comments>http://fendou.org/2010/03/07/mysql-view/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 16:12:09 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=663</guid>
		<description><![CDATA[一． 视图概述 视图是一个虚拟表，其内容由查询定义。同真实的表一样，视图包含一系列带有名称的列和行数据。但是，视图并不在数据库中以存储的数据值集形式存在。行和列数据来自由定义视图的查询所引用的表，并且在引用视图时动态生成。 对其中所引用的基础表来说，视图的作用类似于筛选。定义视图的筛选可以来自当前或其它数据库的一个或多个表，或者其它视图。通过视图进行查询没有任何限制，通过它们进行数据修改时的限制也很少。 视图是存储在数据库中的查询的SQL 语句，它主要出于两种原因：安全原因， 视图可以隐藏一些数据，如：社会保险基金表，可以用视图只显示姓名，地址，而不显示社会保险号和工资数等，另一原因是可使复杂的查询易于理解和使用。 　　视图：查看图形或文档的方式。 　　视图是从一个或多个表或视图中导出的表，其结构和数据是建立在对表的查询基础上的。和表一样，视图也是包括几个被定义的数据列和多个数据行，但就本质而言这些数据列和数据行来源于其所引用的表。 　　所以视图不是真实存在的基础表而是一张虚表，视图所对应的数据并不实际地以视图结构存储在数据库中，而是存储在视图所引用的表中。 　　视图一经定义便存储在数据库中，与其相对应的数据并没有像表那样又在数据库中再存储一份，通过视图看到的数据只是存放在基本表中的数据。对视图的操作与对表的操作一样，可以对其进行查询、修改(有一定的限制)、删除。 　　当对通过视图看到的数据进行修改时，相应的基本表的数据也要发生变化，同时，若基本表的数据发生变化，则这种变化也可以自动地反映到视图中。 　　视图有很多优点，主要表现在： 　　•视点集中 　　•简化操作 　　•定制数据 　　•合并分割数据 　　•安全性 当然视图也存在一些缺点，最大的缺点就是视图带来的更新负担，比如源数据改了，那么视图中要做相应更新，视图中数据改了源数据也要做同步，这和MySQL的Cache差不多。 二． 创建视图——CREATE VIEW 1. 语法 CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED &#124; MERGE &#124; TEMPTABLE}] VIEW [db_name.]view_name [(column_list)] AS select_statement [WITH [CASCADED &#124; LOCAL] CHECK OPTION]通过该语句可以创建视图，若给定了[OR REPLACE]，则表示当已具有同名的视图时，将覆盖原视图。select_statement是一个查询语句，这个查询语句可从表或其它的视图中查询。视图属于数据库，因此需要指定数据库的名称，若未指定时，表示在当前的数据库创建新视图。 表和数据库共享数据库中相同的名称空间，因此，数据库不能包含相同名称的表和视图，并且，视图的列名也不能重复。 2. 使用举例 Eg. 本例创建一个产品表（product）和一个购买记录表（purchase），再通过视图purchase_detail查询出购买的详细信息。 CREATE TABLE product (...  <a href="http://fendou.org/2010/03/07/mysql-view/" class="more-link" title="Read MySQL视图介绍">Read more &#187;</a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F02%2F26%2Fmysql-trigger-one%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL触发器介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>一． 视图概述<br />
视图是一个虚拟表，其内容由查询定义。同真实的表一样，视图包含一系列带有名称的列和行数据。但是，视图并不在数据库中以存储的数据值集形式存在。行和列数据来自由定义视图的查询所引用的表，并且在引用视图时动态生成。</p>
<p>对其中所引用的基础表来说，视图的作用类似于筛选。定义视图的筛选可以来自当前或其它数据库的一个或多个表，或者其它视图。通过视图进行查询没有任何限制，通过它们进行数据修改时的限制也很少。</p>
<p>视图是存储在数据库中的查询的SQL 语句，它主要出于两种原因：安全原因， 视图可以隐藏一些数据，如：社会保险基金表，可以用视图只显示姓名，地址，而不显示社会保险号和工资数等，另一原因是可使复杂的查询易于理解和使用。</p>
<p>　　视图：查看图形或文档的方式。</p>
<p>　　视图是从一个或多个表或视图中导出的表，其结构和数据是建立在对表的查询基础上的。和表一样，视图也是包括几个被定义的数据列和多个数据行，但就本质而言这些数据列和数据行来源于其所引用的表。</p>
<p>　　所以视图不是真实存在的基础表而是一张虚表，视图所对应的数据并不实际地以视图结构存储在数据库中，而是存储在视图所引用的表中。</p>
<p>　　视图一经定义便存储在数据库中，与其相对应的数据并没有像表那样又在数据库中再存储一份，通过视图看到的数据只是存放在基本表中的数据。对视图的操作与对表的操作一样，可以对其进行查询、修改(有一定的限制)、删除。</p>
<p>　　当对通过视图看到的数据进行修改时，相应的基本表的数据也要发生变化，同时，若基本表的数据发生变化，则这种变化也可以自动地反映到视图中。</p>
<p>　　视图有很多优点，主要表现在：<br />
　　•视点集中<br />
　　•简化操作<br />
　　•定制数据<br />
　　•合并分割数据<br />
　　•安全性<br />
当然视图也存在一些缺点，最大的缺点就是视图带来的更新负担，比如源数据改了，那么视图中要做相应更新，视图中数据改了源数据也要做同步，这和MySQL的Cache差不多。</p>
<p>二． 创建视图——CREATE VIEW</p>
<p>1. 语法</p>
<p>CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] VIEW [db_name.]view_name [(column_list)] AS select_statement [WITH [CASCADED | LOCAL] CHECK OPTION]通过该语句可以创建视图，若给定了[OR REPLACE]，则表示当已具有同名的视图时，将覆盖原视图。select_statement是一个查询语句，这个查询语句可从表或其它的视图中查询。视图属于数据库，因此需要指定数据库的名称，若未指定时，表示在当前的数据库创建新视图。</p>
<p>表和数据库共享数据库中相同的名称空间，因此，数据库不能包含相同名称的表和视图，并且，视图的列名也不能重复。</p>
<p>2. 使用举例</p>
<p>Eg. 本例创建一个产品表（product）和一个购买记录表（purchase），再通过视图purchase_detail查询出购买的详细信息。</p>
<p>CREATE TABLE product</p>
<p>(</p>
<p>product_id INT NOT NULL,</p>
<p>name VARCHAR(50) NOT NULL,</p>
<p>price DOUBLE NOT NULL</p>
<p>);</p>
<p>INSERT INTO product VALUES(1, &#8216;apple &#8216;, 5.5);</p>
<p>CREATE TABLE purchase</p>
<p>(</p>
<p>id INT NOT NULL,</p>
<p>product_id INT NOT NULL,</p>
<p>qty INT NOT NULL DEFAULT 0,</p>
<p>gen_time DATETIME NOT NULL</p>
<p>);</p>
<p>INSERT INTO purchase VALUES(1, 1, 10, NOW());</p>
<p>CREATE VIEW purchase_detail AS SELECT product.name as name, product .price as price, purchase.qty as qty, product .price * purchase.qty as total_value from product, purchase where product.product_id = purchase.product_id;</p>
<p>创建成功后，输入：SELECT * FROM purchase_detail;</p>
<p>运行效果如下：</p>
<p>+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+</p>
<p>| name | price | qty | total_value |</p>
<p>+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+</p>
<p>| apple | 5.5 | 10 | 55 |</p>
<p>+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+</p>
<p>1 row in set (0.01 sec)</p>
<p>3. 注意事项</p>
<p>创建视图存在如下注意事项：</p>
<p>（1） 运行创建视图的语句需要用户具有创建视图（CRATE VIEW）的权限，若加了[OR REPLACE]时，还需要用户具有删除视图（DROP VIEW）的权限；</p>
<p>（2） SELECT语句不能包含FROM子句中的子查询；</p>
<p>（3） SELECT语句不能引用系统或用户变量；</p>
<p>（4） SELECT语句不能引用预处理语句参数；</p>
<p>（5） 在存储子程序内，定义不能引用子程序参数或局部变量；</p>
<p>（6） 在定义中引用的表或视图必须存在。但是，创建了视图后，能够舍弃定义引用的表或视图。要想检查视图定义是否存在这类问题，可使用CHECK TABLE语句；</p>
<p>（7） 在定义中不能引用TEMPORARY表，不能创建TEMPORARY视图；</p>
<p>（8） 在视图定义中命名的表必须已存在；</p>
<p>（9） 不能将触发程序与视图关联在一起；</p>
<p>（10） 在视图定义中允许使用ORDER BY，但是，如果从特定视图进行了选择，而该视图使用了具有自己ORDER BY的语句，它将被忽略。</p>
<p>三． 修改视图——ALTER VIEW</p>
<p>1. 语法</p>
<p>ALTER [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] VIEW view_name [(column_list)] AS select_statement [WITH [CASCADED | LOCAL] CHECK OPTION]该语句用于更改已有视图的定义。其语法与CREATE VIEW类似。</p>
<p>2. 使用举例</p>
<p>Eg. 将上一小节中中创建的视purchase_detail进行修改，去掉qty列，语句如下：</p>
<p>ALTER VIEW purchase_detail AS SELECT product.name as name, product .price as price, product .price * purchase.qty as total_value from product, purchase where product.product_id = purchase.product_id;</p>
<p>此时通过语句：select * from purchase_detail;对视图进行查询时，结果如下：</p>
<p>+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+<br />
| name | price | total_value |</p>
<p>+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+</p>
<p>| apple | 5.5 | 55 |</p>
<p>+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+</p>
<p>3. 注意事项</p>
<p>修改视图的注意事项除了第一条外跟创建视图的注意事项是一样的。第（1）条应改为：</p>
<p>该语句需要具有针对视图的CREATE VIEW和DROP权限，也需要针对SELECT语句中引用的每一列的某些权限。</p>
<p>四． 删除视图——DROP VIEW</p>
<p>1. 语法</p>
<p>DROP VIEW [IF EXISTS] view_name [, view_name] &#8230; [RESTRICT | CASCADE]该语句用户删除视图，可一次删除多个视图。[IF EXISTS]选项确保语句正确运行。若没有该子句，当指定的视图不存在时，将发生错误。</p>
<p>2. 使用举例</p>
<p>Eg1. 删除在前面的小节中创建的视图purchase_detail：DROP VIEW purchase_detail;</p>
<p>Eg2. 删除一个未知的视图：DROP VIEW IF EXISTS test_view;</p>
<p>Eg3. 删除多个视图：DROP VIEW IF EXISTS test_view1, test_view2;</p>
<p>3. 注意事项</p>
<p>必须对要删除的一个或多个视图拥有DROP VIEW的权限。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F02%2F26%2Fmysql-trigger-one%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL触发器介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql%25E5%2586%2599%25E5%2585%25A5%25E4%25BC%2598%25E5%258C%2596%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL写入优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2009%2F01%2F20%2Fmysql-heap%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql内存表heap使用总结</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F08%2F30%2Fmysql-limit-opt%2F&from=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">mysql分页limit 优化</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2010/03/07/mysql-view/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>论坛程序设计的思考</title>
		<link>http://fendou.org/2009/08/07/think-for-bbs/</link>
		<comments>http://fendou.org/2009/08/07/think-for-bbs/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 03:02:47 +0000</pubDate>
		<dc:creator>崔玉松</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PhpWind]]></category>

		<guid isPermaLink="false">http://fendou.org/?p=561</guid>
		<description><![CDATA[新入公司，项目被老同志分的七七八八，系统还没有足够的熟悉，暂时清闲了几天，看了几天的代码，有面向对象的，更多的是面向过程的，这篇博文的title值得商榷的，反正我不知道该取什么名字，姑且唬人一下。 1）设计目标，任何软件都需要一个设计目标，比如目标用户，并发数等等，论坛这个东西实时性很强，同时在线人数一般不高，如果很高的话一般会自己做，或者请公司定制开发或优化。撑死了几千人同时在线，很多论坛的设计目标就是没有目标，看到好的功能和界面，拿过来，改改，堆上去，完事 2）模块划分，市面上的几个论坛软件大多还是沿用了N多年前的架构，面向过程，而且过程不清晰，虽然在用户后台看上去好像各个功能挺独立的，看看代码就知道，里面定义了一堆全局变量，更奇怪的是没有注释，还有好几个是没用的，代码重复率非常高，require来include去，绕啊，绕啊，我就晕了~~，功能模块都没能独立，更没法谈耦合和内聚了~ 3）数据库设计，这个挺有意思的，曾经“有幸”阅读过discuz不知道几点几版本的代码，里面的SQL写得令人毛骨悚然，不得不佩服写这个SQL语句程序员的数据库造诣之深，反正我是没写过，也写不出来，我的原则是，能一次查询的不做两次查，能不用jion的就坚决不用，discuz的表有上百个之多，phpwind更是超过150个，且有不断增加之趋势，清一色使用mysql，而且还是用的MYISAM引擎，好吧，1000个并发的时候，discuz 7是挂掉了，phpwind没测试过，暂时不评论。数据表设计时冗余是必要的，不一定非要遵循范式规则，过度随意就成了灾难，我看到数据库中居然有q1,q2,q3一直到q21这样的字段，通通都是int型的，而且绝大部分都是空的，浪费空间之严重令人非常惊讶，且不说这个命名十分之不友好，这个东西能这样做的么，假如真的需要21个同样类型的q这种东西，为啥不再分一张表，然后给个ID连接一下不就好了么，这仅仅是一个例子，N张表都能找到这样的例子。用户表是论坛的核心表之一，论坛有积分啊，签名啊，生日啊，等级啊，权限啊之类之类的，用户属性自然是多之又多，可是再多也不能全放一个表里，一个表里有六七十个属性，这像话么！！绝大部分属性普通用户都是空的，又是一个“占着茅坑不拉屎”的表设计，大部分用户注册时能不填的肯定不会填，就那么昵称啊，email啊，密码啊几个字段需要insert，至于牵动六七十个属性同时更改一遍么，myisam引擎insert是加的是表级锁的啊，郁闷，纵向拆分这张表！ 4）错误处理，出错了，前面加个@好了，让别人都看不到就不会有什么问题了，嗯，这个似乎是可以防止因为出错信息而泄漏一些东西，可是总得让自己知道怎么回事啊，不然怎么解决呢，还好都有官方论坛可以去问，大多数时候管理员也不知道用户出了什么问题，只能靠猜，为什么不记录一个log呢？！ 5）不想说了~~先把前面的改了再说……<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp2%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对PHP记事本程序（二）的修订</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP记事本程序（三）----持续改进</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>新入公司，项目被老同志分的七七八八，系统还没有足够的熟悉，暂时清闲了几天，看了几天的代码，有面向对象的，更多的是面向过程的，这篇博文的title值得商榷的，反正我不知道该取什么名字，姑且唬人一下。</p>
<p>1）设计目标，任何软件都需要一个设计目标，比如目标用户，并发数等等，论坛这个东西实时性很强，同时在线人数一般不高，如果很高的话一般会自己做，或者请公司定制开发或优化。撑死了几千人同时在线，很多论坛的设计目标就是没有目标，看到好的功能和界面，拿过来，改改，堆上去，完事</p>
<p>2）模块划分，市面上的几个论坛软件大多还是沿用了N多年前的架构，面向过程，而且过程不清晰，虽然在用户后台看上去好像各个功能挺独立的，看看代码就知道，里面定义了一堆全局变量，更奇怪的是没有注释，还有好几个是没用的，代码重复率非常高，require来include去，绕啊，绕啊，我就晕了~~，功能模块都没能独立，更没法谈耦合和内聚了~</p>
<p>3）数据库设计，这个挺有意思的，曾经“有幸”阅读过discuz不知道几点几版本的代码，里面的SQL写得令人毛骨悚然，不得不佩服写这个SQL语句程序员的数据库造诣之深，反正我是没写过，也写不出来，我的原则是，能一次查询的不做两次查，能不用jion的就坚决不用，discuz的表有上百个之多，phpwind更是超过150个，且有不断增加之趋势，清一色使用mysql，而且还是用的MYISAM引擎，好吧，1000个并发的时候，discuz 7是挂掉了，phpwind没测试过，暂时不评论。数据表设计时冗余是必要的，不一定非要遵循范式规则，过度随意就成了灾难，我看到数据库中居然有q1,q2,q3一直到q21这样的字段，通通都是int型的，而且绝大部分都是空的，浪费空间之严重令人非常惊讶，且不说这个命名十分之不友好，这个东西能这样做的么，假如真的需要21个同样类型的q这种东西，为啥不再分一张表，然后给个ID连接一下不就好了么，这仅仅是一个例子，N张表都能找到这样的例子。用户表是论坛的核心表之一，论坛有积分啊，签名啊，生日啊，等级啊，权限啊之类之类的，用户属性自然是多之又多，可是再多也不能全放一个表里，一个表里有六七十个属性，这像话么！！绝大部分属性普通用户都是空的，又是一个“占着茅坑不拉屎”的表设计，大部分用户注册时能不填的肯定不会填，就那么昵称啊，email啊，密码啊几个字段需要insert，至于牵动六七十个属性同时更改一遍么，myisam引擎insert是加的是表级锁的啊，郁闷，纵向拆分这张表！</p>
<p>4）错误处理，出错了，前面加个@好了，让别人都看不到就不会有什么问题了，嗯，这个似乎是可以防止因为出错信息而泄漏一些东西，可是总得让自己知道怎么回事啊，不然怎么解决呢，还好都有官方论坛可以去问，大多数时候管理员也不知道用户出了什么问题，只能靠猜，为什么不记录一个log呢？！</p>
<p>5）不想说了~~先把前面的改了再说……</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp2%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对PHP记事本程序（二）的修订</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2008%2F07%2F10%2Fphp%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP记事本程序（三）----持续改进</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F05%2F28%2Fphp-mysql-procedure%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">PHP中操作mysql执行存储过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2010%2F03%2F07%2Fmysql-view%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL视图介绍</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Ffendou.org%2F2011%2F05%2F06%2Fmysql-communication-protocols%2F&from=http%3A%2F%2Ffendou.org%2F2009%2F08%2F07%2Fthink-for-bbs%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL通信协议</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://fendou.org/2009/08/07/think-for-bbs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

