﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Titan专栏-文章分类-MS SQLServer</title><link>http://www.blogjava.net/Titan/category/6840.html</link><description>用文字来整理生命</description><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2007 02:44:13 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2007 02:44:13 GMT</pubDate><ttl>60</ttl><item><title>[转]SQLServer 2000无法打开1433端口</title><link>http://www.blogjava.net/Titan/articles/31110.html</link><dc:creator>Titan</dc:creator><author>Titan</author><pubDate>Thu, 16 Feb 2006 15:17:00 GMT</pubDate><guid>http://www.blogjava.net/Titan/articles/31110.html</guid><wfw:comment>http://www.blogjava.net/Titan/comments/31110.html</wfw:comment><comments>http://www.blogjava.net/Titan/articles/31110.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Titan/comments/commentRss/31110.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Titan/services/trackbacks/31110.html</trackback:ping><description><![CDATA[windows203+sql server 2000无法打开1433端口 <BR>1.如果你是win2003,那么一定要安装sql的补丁sp3a <BR><BR>检查你的SQL有没有打补丁,没有的话要打上补丁,检查的方法是在查询分析器中运行: <BR>select @@version <BR>如果出来的版本号是8.00.760以下,则表明你未安装sp3的补丁,要装上. <BR><BR>SQL补丁下载: <BR>全部补丁的位置 <BR><A href="http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&amp;FamilyID=9032f608-160a-4537-a2b6-4cb265b80766" target=_blank>http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&amp;FamilyID=9032f608-160a-4537-a2b6-4cb265b80766</A> <BR><BR>注意下载后,执行的时候是解压,要在解压后的目录中执行setup.bat才是真正的安装 <BR><BR>2.SQL Server连接中的四个最常见错误: <BR><BR><BR>一."SQL Server 不存在或访问被拒绝" <BR><BR>这个是最复杂的,错误发生的原因比较多,需要检查的方面也比较多. <BR><BR>一般说来,有以下几种可能性: <BR><BR>1,SQL Server名称或IP地址拼写有误 <BR>2,服务器端网络配置有误 <BR>3,客户端网络配置有误 <BR><BR>要解决这个问题,我们一般要遵循以下的步骤来一步步找出导致错误的原因. <BR><BR><BR>============= 首先,检查网络物理连接 ============= <BR>ping &lt;服务器IP地址/服务器名称&gt; <BR><BR>如果 ping &lt;服务器IP地址&gt; 不成功,说明物理连接有问题,这时候要检查硬件设备,如网卡,HUB,路由器等. <BR>还有一种可能是由于客户端和服务器之间安装有防火墙软件造成的,比如 ISA Server.防火墙软件可能会屏蔽对 ping,telnet 等的响应 <BR>因此在检查连接问题的时候,我们要先把防火墙软件暂时关闭,或者打开所有被封闭的端口. <BR><BR>如果ping &lt;服务器IP地址&gt; 成功而,ping &lt;服务器名称&gt; 失败 <BR>则说明名字解析有问题,这时候要检查 DNS 服务是否正常. <BR>有时候客户端和服务器不在同一个局域网里面,这时候很可能无法直接使用服务器名称来标识该服务器,这时候我们可以使用HOSTS文件来进行名字解析, <BR>具体的方法是: <BR><BR>1.使用记事本打开HOSTS文件（一般情况下位于C:\WINNT\system32\drivers\etc）. <BR>添加一条IP地址与服务器名称的对应记录,如: <BR>172.168.10.24 myserver <BR><BR>2.或在 SQL Server 的客户端网络实用工具里面进行配置,后面会有详细说明. <BR><BR><BR>============= 其次,使用 telnet 命令检查SQL Server服务器工作状态 ============= <BR>telnet &lt;服务器IP地址&gt; 1433 <BR><BR>如果命令执行成功,可以看到屏幕一闪之后光标在左上角不停闪动,这说明 SQL Server 服务器工作正常,并且正在监听1433端口的 TCP/IP 连接 <BR>如果命令返回"无法打开连接"的错误信息,则说明服务器端没有启动 SQL Server 服务, <BR>也可能服务器端没启用 TCP/IP 协议,或者服务器端没有在 SQL Server 默认的端口1433上监听. <BR><BR><BR>=============接着,我们要到服务器上检查服务器端的网络配置,检查是否启用了命名管道.是否启用了 TCP/IP 协议等等 ============= <BR>可以利用 SQL Server 自带的服务器网络使用工具来进行检查. <BR><BR>点击:程序 -- Microsoft SQL Server -- 服务器网络使用工具 <BR><BR>打开该工具后,在"常规"中可以看到服务器启用了哪些协议. <BR>一般而言,我们启用命名管道以及 TCP/IP 协议. <BR>点中 TCP/IP 协议,选择"属性",我们可以来检查 SQK Server 服务默认端口的设置 <BR>一般而言,我们使用 SQL Server 默认的1433端口.如果选中"隐藏服务器",则意味着客户端无法通过枚举服务器来看到这台服务器,起到了保护的作用,但不影响连接. <BR><BR><BR>============= 接下来我们要到客户端检查客户端的网络配置 ============= <BR>我们同样可以利用 SQL Server 自带的客户端网络使用工具来进行检查, <BR>所不同的是这次是在客户端来运行这个工具. <BR><BR>点击:程序 -- Microsoft SQL Server -- 客户端网络使用工具 <BR><BR>打开该工具后,在"常规"项中,可以看到客户端启用了哪些协议. <BR>一般而言,我们同样需要启用命名管道以及 TCP/IP 协议. <BR>点击 TCP/IP 协议,选择"属性",可以检查客户端默认连接端口的设置,该端口必须与服务器一致. <BR><BR>单击"别名"选项卡,还可以为服务器配置别名.服务器的别名是用来连接的名称, <BR>连接参数中的服务器是真正的服务器名称,两者可以相同或不同.别名的设置与使用HOSTS文件有相似之处. <BR><BR><BR>通过以上几个方面的检查,基本上可以排除第一种错误. <BR><BR><BR>----------------------------------------------------------------------------- <BR><BR>二."无法连接到服务器,用户xxx登陆失败" <BR><BR>该错误产生的原因是由于SQL Server使用了"仅 Windows"的身份验证方式, <BR>因此用户无法使用SQL Server的登录帐户（如 sa ）进行连接.解决方法如下所示: <BR><BR>1.在服务器端使用企业管理器,并且选择"使用 Windows 身份验证"连接上 SQL Server <BR>在企业管理器中 <BR>--右键你的服务器实例(就是那个有绿色图标的) <BR>--编辑SQL Server注册属性 <BR>--选择"使用windows身份验证" <BR><BR>2.展开"SQL Server组",鼠标右键点击SQL Server服务器的名称,选择"属性",再选择"安全性"选项卡 <BR>3.在"身份验证"下,选择"SQL Server和 Windows ". <BR>4.重新启动SQL Server服务. <BR><BR>在以上解决方法中,如果在第 1 步中使用"使用 Windows 身份验证"连接 SQL Server 失败, <BR>那就通过修改注册表来解决此问题: <BR><BR>1.点击"开始"-"运行",输入regedit,回车进入注册表编辑器 <BR>2.依次展开注册表项,浏览到以下注册表键: <BR>[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer] <BR>3.在屏幕右方找到名称"LoginMode",双击编辑双字节值 <BR>4.将原值从1改为2,点击"确定" <BR>5.关闭注册表编辑器 <BR>6.重新启动SQL Server服务. <BR><BR>此时,用户可以成功地使用sa在企业管理器中新建SQL Server注册, <BR>但是仍然无法使用Windows身份验证模式来连接SQL Server. <BR>这是因为在 SQL Server 中有两个缺省的登录帐户: <BR>BUILTIN\Administrators <BR>&lt;机器名&gt;\Administrator 被删除. <BR>要恢复这两个帐户,可以使用以下的方法: <BR><BR>1.打开企业管理器,展开服务器组,然后展开服务器 <BR>2.展开"安全性",右击"登录",然后单击"新建登录" <BR>3.在"名称"框中,输入 BUILTIN\Administrators <BR>4.在"服务器角色"选项卡中,选择"System Administrators" <BR>5.点击"确定"退出 <BR>6.使用同样方法添加 &lt;机器名&gt;\Administrator 登录. <BR><BR>说明: <BR><BR>以下注册表键: <BR>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\LoginMode <BR>的值决定了SQL Server将采取何种身份验证模式. <BR>1.表示使用"Windows 身份验证"模式 <BR>2.表示使用混合模式（Windows 身份验证和 SQL Server 身份验证）. <BR><BR><BR>----------------------------------------------------------------------------- <BR><BR>三.提示连接超时 <BR><BR>如果遇到第三个错误,一般而言表示客户端已经找到了这台服务器,并且可以进行连接, <BR>不过是由于连接的时间大于允许的时间而导致出错. <BR>这种情况一般会发生在当用户在Internet上运行企业管理器来注册另外一台同样在Internet上的服务器, <BR>并且是慢速连接时,有可能会导致以上的超时错误.有些情况下,由于局域网的网络问题,也会导致这样的错误. <BR><BR>要解决这样的错误,可以修改客户端的连接超时设置. <BR>默认情况下,通过企业管理器注册另外一台SQL Server的超时设置是 4 秒, <BR>而查询分析器是 15 秒（这也是为什么在企业管理器里发生错误的可能性比较大的原因）. <BR><BR>具体步骤为: <BR>企业管理器中的设置: <BR>1.在企业管理器中,选择菜单上的"工具",再选择"选项" <BR>2.在弹出的"SQL Server企业管理器属性"窗口中,点击"高级"选项卡 <BR>3.在"连接设置"下的"登录超时（秒）"右边的框中输入一个比较大的数字,如 20. <BR><BR>查询分析器中的设置: <BR>工具 -- 选项 -- 连接 -- 将登录超时设置为一个较大的数字 <BR><BR><BR>--------------------------------------------------------------------------------- <BR><BR>四.大部分机都用Tcp/ip才能成功，有次我发现用Named Pipes才可以？ <BR><BR>回复人： leimin(黄山光明顶) <BR><BR>这是因为在WINDOWS 2000以后的操作系统中，MS为解决SQL SERVER的安全问题将TCP/IP配置 <BR>为SQLSERVER的默认连接协议，你可以在CLIENT NETWORK UTILITY中看到TCP/IP和NAME PIPE <BR>的顺序。 <BR><BR>你也可以在： <BR>[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib] <BR>"ProtocolOrder"=hex(7):74,00,63,00,70,00,00,00,00,00 <BR>看到默认的协议。 <BR><BR>2.怎么在程序中更改Named Pipes ， Tcp/ip ，其sql语句怎么写？ <BR>你可以在上面提到的注册表的位置修改： <BR>CLIENT端： <BR>[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib] <BR>"ProtocolOrder"=hex(7):74,00,63,00,70,00,00,00,00,00 <BR><BR>SERVER端： <BR>[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib] <BR>"ProtocolOrder"=hex(7):74,00,63,00,70,00,00,00,00,00 <BR><BR>SQL中,连接的配置就这两个方面 <BR><BR>SQL Server服务器--开始--程序--Microsoft SQL Server <BR>--服务器网络实用工具 <BR>--启用 WinSock代理 <BR>--代理地址:(sqlserver服务器IP) <BR>--代理端口--1433 <BR>---确定 <BR><BR>客户端 <BR>开始--程序--Microsoft SQL Server--客户端网络实用工具 <BR>--别名--添加 <BR>--网络库选择"tcp/ip"--服务器别名输入SQL服务器名 <BR>--连接参数--服务器名称中输入SQL服务器ip地址 <BR>--如果你修改了SQL的端口,取消选择"动态决定端口",并输入对应的端口号 <img src ="http://www.blogjava.net/Titan/aggbug/31110.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Titan/" target="_blank">Titan</a> 2006-02-16 23:17 <a href="http://www.blogjava.net/Titan/articles/31110.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL语句优化技术分析</title><link>http://www.blogjava.net/Titan/articles/30381.html</link><dc:creator>Titan</dc:creator><author>Titan</author><pubDate>Sun, 12 Feb 2006 14:05:00 GMT</pubDate><guid>http://www.blogjava.net/Titan/articles/30381.html</guid><wfw:comment>http://www.blogjava.net/Titan/comments/30381.html</wfw:comment><comments>http://www.blogjava.net/Titan/articles/30381.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Titan/comments/commentRss/30381.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Titan/services/trackbacks/30381.html</trackback:ping><description><![CDATA[<DIV class=daxiao14 align=left>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符优化</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>IN </SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符</SPAN><SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用</SPAN><SPAN lang=EN-US>IN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">写出来的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的优点是比较容易写及清晰易懂，这比较适合现代软件开发的风格。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">但是用</SPAN><SPAN lang=EN-US>IN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">性能总是比较低的，从</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行的步骤来分析用</SPAN><SPAN lang=EN-US>IN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与不用</SPAN><SPAN lang=EN-US>IN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有以下区别：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试图将其转换成多个表的连接，如果转换不成功则先执行</SPAN><SPAN lang=EN-US>IN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里面的子查询，再查询外层的表记录，如果转换成功则直接采用多个表的连接方式查询。由此可见用</SPAN><SPAN lang=EN-US>IN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">至少多了一个转换的过程。一般的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">都可以转换成功，但对于含有分组统计等方面的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就不能转换了。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐方案：在业务密集的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当中尽量不采用</SPAN><SPAN lang=EN-US>IN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>NOT IN</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此操作是强列推荐不使用的，因为它不能应用表的索引。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐方案：用</SPAN><SPAN lang=EN-US>NOT EXISTS </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或（外连接</SPAN><SPAN lang=EN-US>+</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断为空）方案代替</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>&lt;&gt; </SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符（不等于）</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不等于操作符是永远不会用到索引的，因此对它的处理只会产生全表扫描。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐方案：用其它相同功能的操作运算代替，如</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>a&lt;&gt;0 </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">改为</SPAN><SPAN lang=EN-US> a&gt;0 or a&lt;0</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>a&lt;&gt;’’ </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">改为</SPAN><SPAN lang=EN-US> a&gt;’’</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>IS NULL </SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或</SPAN><SPAN lang=EN-US>IS NOT NULL</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作（判断字段是否为空）</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断字段是否为空一般是不会应用索引的，因为</SPAN><SPAN lang=EN-US>B</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">树索引是不索引空值的。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐方案：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用其它相同功能的操作运算代替，如</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>a is not null </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">改为</SPAN><SPAN lang=EN-US> a&gt;0 </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或</SPAN><SPAN lang=EN-US>a&gt;’’</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不允许字段为空，而用一个缺省值代替空值，如业扩申请中状态字段不允许为空，缺省为申请。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立位图索引（有分区的表不能建，位图索引比较难控制，如字段值太多索引会使性能下降，多人更新操作会增加数据块锁的现象）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>&gt; </SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">及</SPAN><SPAN lang=EN-US> &lt; </SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符（大于或小于操作符）</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">大于或小于操作符一般情况下是不用调整的，因为它有索引就会采用索引查找，但有的情况下可以对它进行优化，如一个表有</SPAN><SPAN lang=EN-US>100</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">万记录，一个数值型字段</SPAN><SPAN lang=EN-US>A</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US>30</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">万记录的</SPAN><SPAN lang=EN-US>A=0</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US>30</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">万记录的</SPAN><SPAN lang=EN-US>A=1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US>39</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">万记录的</SPAN><SPAN lang=EN-US>A=2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">万记录的</SPAN><SPAN lang=EN-US>A=3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。那么执行</SPAN><SPAN lang=EN-US>A&gt;2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与</SPAN><SPAN lang=EN-US>A&gt;=3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的效果就有很大的区别了，因为</SPAN><SPAN lang=EN-US>A&gt;2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">时</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会先找出为</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的记录索引再进行比较，而</SPAN><SPAN lang=EN-US>A&gt;=3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">时</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">则直接找到</SPAN><SPAN lang=EN-US>=3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的记录索引。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>LIKE</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>LIKE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符可以应用通配符查询，里面的通配符组合可能达到几乎是任意的查询，但是如果用得不好则会产生性能上的问题，如</SPAN><SPAN lang=EN-US>LIKE ‘%5400%’ </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这种查询不会引用索引，而</SPAN><SPAN lang=EN-US>LIKE ‘X5400%’</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">则会引用范围索引。一个实际例子：用</SPAN><SPAN lang=EN-US>YW_YHJBQK</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表中营业编号后面的户标识号可来查询营业编号</SPAN><SPAN lang=EN-US> YY_BH LIKE ‘%5400%’ </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这个条件会产生全表扫描，如果改成</SPAN><SPAN lang=EN-US>YY_BH LIKE ’X5400%’ OR YY_BH LIKE ’B5400%’ </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">则会利用</SPAN><SPAN lang=EN-US>YY_BH</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的索引进行两个范围的查询，性能肯定大大提高。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>UNION</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>UNION</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在进行表链接后会筛选掉重复的记录，所以在表链接后会对所产生的结果集进行排序运算，删除重复的记录再返回结果。实际大部分应用中是不会产生重复的记录，最常见的是过程表与历史表</SPAN><SPAN lang=EN-US>UNION</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。如：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>select * from gc_dfys</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>union</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>select * from ls_jg_dfys</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这个</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在运行时先取出两个表的结果，再用排序空间进行排序删除重复的记录，最后返回结果集，如果表数据量大的话可能会导致用磁盘进行排序。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐方案：采用</SPAN><SPAN lang=EN-US>UNION ALL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作符替代</SPAN><SPAN lang=EN-US>UNION</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，因为</SPAN><SPAN lang=EN-US>UNION ALL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作只是简单的将两个结果合并后就返回。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>select * from gc_dfys</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>union all</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>select * from ls_jg_dfys</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">书写的影响</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">同一功能同一性能不同写法</SPAN><SPAN lang=EN-US>SQL</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的影响</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如一个</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN lang=EN-US>A</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序员写的为</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Select * from zl_yhjbqk</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>B</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序员写的为</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Select * from dlyx.zl_yhjbqk</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（带表所有者的前缀）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>C</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序员写的为</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Select * from DLYX.ZLYHJBQK</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（大写表名）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>D</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序员写的为</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Select *<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>from DLYX.ZLYHJBQK</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（中间多了空格）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">以上四个</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分析整理之后产生的结果及执行的时间是一样的，但是从</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共享内存</SPAN><SPAN lang=EN-US>SGA</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的原理，可以得出</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对每个</SPAN><SPAN lang=EN-US>SQL </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">都会对其进行一次分析，并且占用共享内存，如果将</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的字符串及格式写得完全相同则</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">只会分析一次，共享内存也只会留下一次的分析结果，这不仅可以减少分析</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的时间，而且可以减少共享内存重复的信息，</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">也可以准确统计</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的执行频率。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>WHERE</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后面的条件顺序影响</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>WHERE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">子句后面的条件顺序对大数据量表的查询会产生直接的影响，如</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">Select * from zl_yhjbqk where dy_dj = '1KV</SPAN></B><B><SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'">以下</SPAN></B><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">' and xh_bz=1</SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">Select * from zl_yhjbqk where xh_bz=1<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>and dy_dj = '1KV</SPAN></B><B><SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'">以下</SPAN></B><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">'</SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">以上两个</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'; mso-bidi-font-size: 8.0pt">dy_dj</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'; mso-bidi-font-size: 8.0pt">（电压等级）及<SPAN lang=EN-US>xh_bz</SPAN>（销户标志）两个字段都没进行索引，所以执行的时候都是全表扫描，第一条<SPAN lang=EN-US>SQL</SPAN>的</SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">dy_dj = '1KV</SPAN></B><B><SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'">以下</SPAN></B><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">'</SPAN></B><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'; mso-bidi-font-size: 8.0pt">条件在记录集内比率为<SPAN lang=EN-US>99%</SPAN>，而</SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">xh_bz=1</SPAN></B><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'; mso-bidi-font-size: 8.0pt">的比率只为<SPAN lang=EN-US>0.5%</SPAN>，在进行第一条<SPAN lang=EN-US>SQL</SPAN>的时候<SPAN lang=EN-US>99%</SPAN>条记录都进行</SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">dy_dj</SPAN></B><B><SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'">及</SPAN></B><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">xh_bz</SPAN></B><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'; mso-bidi-font-size: 8.0pt">的比较，而在进行第二条<SPAN lang=EN-US>SQL</SPAN>的时候<SPAN lang=EN-US>0.5%</SPAN>条记录都进行</SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">dy_dj</SPAN></B><B><SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'">及</SPAN></B><B><SPAN lang=EN-US style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">xh_bz</SPAN></B><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'; mso-bidi-font-size: 8.0pt">的比较，以此可以得出第二条<SPAN lang=EN-US>SQL</SPAN>的<SPAN lang=EN-US>CPU</SPAN>占用率明显比第一条低。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">查询表顺序的影响</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN lang=EN-US>FROM</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后面的表中的列表顺序会对</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行性能影响，在没有索引及</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">没有对表进行统计分析的情况下</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会按表出现的顺序进行链接，由此因为表的顺序不对会产生十分耗服务器资源的数据交叉。（注：如果对表进行了统计分析，</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会自动先进小表的链接，再进行大表的链接）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>SQL</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语句索引的利用</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对操作符的优化（见上节）</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对条件字段的一些优化</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">采用函数处理的字段不能利用索引，如：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>substr(hbs_bh,1,4)=’<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="5400" UnitName="’">5400’</st1:chmetcnv></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，优化处理：</SPAN><SPAN lang=EN-US>hbs_bh like ‘5400%’</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US style="FONT-FAMILY: 宋体">trunc(sk_rq)=trunc(sysdate)</SPAN><SPAN style="FONT-FAMILY: 宋体">， 优化处理：<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 'Courier New'; mso-bidi-font-size: 8.0pt">sk_rq&gt;=trunc(<B>sysdate</B>) <B>and</B> sk_rq&lt;trunc(<B>sysdate+1</B>)</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 宋体"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行了显式或隐式的运算的字段不能进行索引，如：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>ss_df+20&gt;50</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，优化处理：</SPAN><SPAN lang=EN-US>ss_df&gt;30</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>‘X’||hbs_bh&gt;’X<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="5400021452" UnitName="’">5400021452’</st1:chmetcnv></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，优化处理：</SPAN><SPAN lang=EN-US>hbs_bh&gt;’<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="5400021542" UnitName="’">5400021542’</st1:chmetcnv></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>sk_rq+5=sysdate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，优化处理：</SPAN><SPAN lang=EN-US>sk_rq=sysdate-5</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>hbs_bh=5401002554</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，优化处理：</SPAN><SPAN lang=EN-US>hbs_bh=’ <st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="5401002554" UnitName="’">5401002554’</st1:chmetcnv></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<B>注：</B>此条件对</SPAN><SPAN lang=EN-US>hbs_bh </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行隐式的</SPAN><SPAN lang=EN-US>to_number</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">转换，因为</SPAN><SPAN lang=EN-US>hbs_bh</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字段是字符型。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">条件内包括了多个本表的字段运算时不能进行索引，如：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>ys_df&gt;cx_df</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，无法进行优化</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>qc_bh||kh_bh=’<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="5400250000" UnitName="’">5400250000’</st1:chmetcnv></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，优化处理：</SPAN><SPAN lang=EN-US>qc_bh=’<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="5400" UnitName="’">5400’</st1:chmetcnv> and kh_bh=’<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="250000" UnitName="’">250000’</st1:chmetcnv></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用</SPAN><SPAN lang=EN-US>ORACLE</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>HINT</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（提示）处理</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提示处理是在</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">产生的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分析执行路径不满意的情况下要用到的。它可以对</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行以下方面的提示</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目标方面的提示：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>COST</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（按成本优化）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>RULE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（按规则优化）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>CHOOSE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（缺省）（</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">自动选择成本或规则进行优化）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>ALL_ROWS</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（所有的行尽快返回）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>FIRST_ROWS</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（第一行数据尽快返回）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行方法的提示：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>USE_NL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（使用</SPAN><SPAN lang=EN-US>NESTED LOOPS</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方式联合）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>USE_MERGE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（使用</SPAN><SPAN lang=EN-US>MERGE JOIN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方式联合）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><SPAN lang=EN-US>USE_HASH</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（使用</SPAN><SPAN lang=EN-US>HASH JOIN</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方式联合）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">索引提示：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>INDEX</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</SPAN><SPAN lang=EN-US>TABLE INDEX</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）（使用提示的表索引进行查询）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其它高级提示（如并行处理等等）</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的提示功能是比较强的功能，也是比较复杂的应用，并且提示只是给</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行的一个建议，有时如果出于成本方面的考虑</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">也可能不会按提示进行。根据实践应用，一般不建议开发人员应用</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提示，因为各个数据库及服务器性能情况不一样，很可能一个地方性能提升了，但另一个地方却下降了，</SPAN><SPAN lang=EN-US>ORACLE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行分析方面已经比较成熟，如果分析执行的路径不对首先应在数据库结构（主要是索引）、服务器当前性能（共享内存、磁盘文件碎片）、数据库对象（表、索引）统计信息是否正确这几方面分析。</SPAN></P></DIV><img src ="http://www.blogjava.net/Titan/aggbug/30381.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Titan/" target="_blank">Titan</a> 2006-02-12 22:05 <a href="http://www.blogjava.net/Titan/articles/30381.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]SQL语句大全 </title><link>http://www.blogjava.net/Titan/articles/27200.html</link><dc:creator>Titan</dc:creator><author>Titan</author><pubDate>Sun, 08 Jan 2006 17:57:00 GMT</pubDate><guid>http://www.blogjava.net/Titan/articles/27200.html</guid><wfw:comment>http://www.blogjava.net/Titan/comments/27200.html</wfw:comment><comments>http://www.blogjava.net/Titan/articles/27200.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Titan/comments/commentRss/27200.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Titan/services/trackbacks/27200.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: --数据操作SELECT --从数据库表中检索数据行和列INSERT --向数据库表添加新数据行DELETE --从数据库表中删除数据行UPDATE --更新数据库表中的数据--数据定义CREATE TABLE --创建一个数据库表DROP TABLE --从数据库中删除表ALTER TABLE --修改数据库表结构CREATE VIEW --创建一个视图DROP VIEW --从数据库中删除视图...&nbsp;&nbsp;<a href='http://www.blogjava.net/Titan/articles/27200.html'>阅读全文</a><img src ="http://www.blogjava.net/Titan/aggbug/27200.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Titan/" target="_blank">Titan</a> 2006-01-09 01:57 <a href="http://www.blogjava.net/Titan/articles/27200.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>