??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲成国产人片在线观看,av在线一区二区三区,国模精品一区二区http://www.aygfsteel.com/Titan/category/6840.html用文字来整理生命zh-cnFri, 02 Mar 2007 02:44:13 GMTFri, 02 Mar 2007 02:44:13 GMT60[转]SQLServer 2000无法打开1433端口http://www.aygfsteel.com/Titan/articles/31110.htmlTitanTitanThu, 16 Feb 2006 15:17:00 GMThttp://www.aygfsteel.com/Titan/articles/31110.htmlhttp://www.aygfsteel.com/Titan/comments/31110.htmlhttp://www.aygfsteel.com/Titan/articles/31110.html#Feedback0http://www.aygfsteel.com/Titan/comments/commentRss/31110.htmlhttp://www.aygfsteel.com/Titan/services/trackbacks/31110.html1.如果你是win2003,那么一定要安装sql的补丁sp3a

查你的SQL有没有打补丁,没有的话要打上补?查的Ҏ是在查询分析器中q行:
select @@version
如果出来的版本号?.00.760以下,则表明你未安装sp3的补?要装?

SQL补丁下蝲:
全部补丁的位|?
http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=9032f608-160a-4537-a2b6-4cb265b80766

注意下蝲?执行的时候是解压,要在解压后的目录中执行setup.bat才是真正的安?

2.SQL Serverq接中的四个最常见错误:


一."SQL Server 不存在或讉K被拒l?

q个是最复杂?错误发生的原因比较多,需要检查的斚w也比较多.

一般说?有以下几U可能?

1,SQL Server名称或IP地址拼写有误
2,服务器端|络配置有误
3,客户端网l配|有?

要解册个问?我们一般要遵@以下的步骤来一步步扑ևD错误的原?


============= 首先,查网l物理连?=============
ping <服务器IP地址/服务器名U?gt;

如果 ping <服务器IP地址> 不成?说明物理q接有问?q时候要查硬件设?如网?HUB,路由器等.
q有一U可能是׃客户端和服务器之间安装有防火墙Y仉成?比如 ISA Server.防火墙Y件可能会屏蔽?ping,telnet {的响应
因此在检查连接问题的时?我们要先把防火墙软g暂时关闭,或者打开所有被闭的端?

如果ping <服务器IP地址> 成功?ping <服务器名U?gt; p|
则说明名字解析有问题,q时候要?DNS 服务是否正常.
有时候客L和服务器不在同一个局域网里面,q时候很可能无法直接使用服务器名U来标识该服务器,q时候我们可以用HOSTS文g来进行名字解?
具体的方法是:

1.使用C本打开HOSTS文gQ一般情况下位于C:\WINNT\system32\drivers\etcQ?
d一条IP地址与服务器名称的对应记??
172.168.10.24 myserver

2.或在 SQL Server 的客L|络实用工具里面q行配置,后面会有详细说明.


============= 其次,使用 telnet 命o查SQL Server服务器工作状?=============
telnet <服务器IP地址> 1433

如果命o执行成功,可以看到屏幕一闪之后光标在左上角不停闪?q说?SQL Server 服务器工作正?q且正在监听1433端口?TCP/IP q接
如果命oq回"无法打开q接"的错误信?则说明服务器端没有启?SQL Server 服务,
也可能服务器端没启用 TCP/IP 协议,或者服务器端没有在 SQL Server 默认的端?433上监?


=============接着,我们要到服务器上查服务器端的|络配置,查是否启用了命名道.是否启用?TCP/IP 协议{等 =============
可以利用 SQL Server 自带的服务器|络使用工具来进行检?

点击:E序 -- Microsoft SQL Server -- 服务器网l用工?

打开该工具后,?常规"中可以看到服务器启用了哪些协?
一般而言,我们启用命名道以及 TCP/IP 协议.
点中 TCP/IP 协议,选择"属?,我们可以来检?SQK Server 服务默认端口的设|?
一般而言,我们使用 SQL Server 默认?433端口.如果选中"隐藏服务?,则意味着客户端无法通过枚D服务器来看到q台服务?起到了保护的作用,但不影响q接.


============= 接下来我们要到客L查客L的网l配|?=============
我们同样可以利用 SQL Server 自带的客L|络使用工具来进行检?
所不同的是q次是在客户端来q行q个工具.

点击:E序 -- Microsoft SQL Server -- 客户端网l用工?

打开该工具后,?常规"中,可以看到客户端启用了哪些协议.
一般而言,我们同样需要启用命名管道以?TCP/IP 协议.
点击 TCP/IP 协议,选择"属?,可以查客L默认q接端口的设|?该端口必M服务器一?

单击"别名"选项?q可以ؓ服务器配|别?服务器的别名是用来连接的名称,
q接参数中的服务器是真正的服务器名称,两者可以相同或不同.别名的设|与使用HOSTS文g有相g?


通过以上几个斚w的检?基本上可以排除第一U错?


-----------------------------------------------------------------------------

?"无法q接到服务器,用户xxx登陆p|"

该错误生的原因是由于SQL Server使用??Windows"的n份验证方?
因此用户无法使用SQL Server的登录帐P?sa Q进行连?解决Ҏ如下所C?

1.在服务器端用企业管理器,q且选择"使用 Windows w䆾验证"q接?SQL Server
在企业管理器?
--右键你的服务器实?是那个有绿色图标的)
--~辑SQL Server注册属?
--选择"使用windowsw䆾验证"

2.展开"SQL Serverl?,鼠标右键点击SQL Server服务器的名称,选择"属?,再选择"安全?选项?
3.?w䆾验证"?选择"SQL Server?Windows ".
4.重新启动SQL Server服务.

在以上解x法中,如果在第 1 步中使用"使用 Windows w䆾验证"q接 SQL Server p|,
那就通过修改注册表来解决此问?

1.点击"开?-"q行",输入regedit,回Rq入注册表编辑器
2.依次展开注册表项,览C下注册表?
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer]
3.在屏q右Ҏ到名U?LoginMode",双击~辑双字节?
4.原g1改ؓ2,点击"定"
5.关闭注册表编辑器
6.重新启动SQL Server服务.

此时,用户可以成功C用sa在企业管理器中新建SQL Server注册,
但是仍然无法使用Windowsw䆾验证模式来连接SQL Server.
q是因ؓ?SQL Server 中有两个~省的登录帐?
BUILTIN\Administrators
<机器?gt;\Administrator 被删?
要恢复这两个帐户,可以使用以下的方?

1.打开企业理?展开服务器组,然后展开服务?
2.展开"安全?,叛_"d",然后单击"新徏d"
3.?名称"框中,输入 BUILTIN\Administrators
4.?服务器角?选项卡中,选择"System Administrators"
5.点击"定"退?
6.使用同样Ҏd <机器?gt;\Administrator d.

说明:

以下注册表键:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\LoginMode
的值决定了SQL Server采取何Un份验证模?
1.表示使用"Windows w䆾验证"模式
2.表示使用混合模式QWindows w䆾验证?SQL Server w䆾验证Q?


-----------------------------------------------------------------------------

?提示q接时

如果遇到W三个错?一般而言表示客户端已l找Cq台服务?q且可以q行q接,
不过是由于连接的旉大于允许的时间而导致出?
q种情况一般会发生在当用户在Internet上运行企业管理器来注册另外一台同样在Internet上的服务?
q且是慢速连接时,有可能会D以上的超旉?有些情况?׃局域网的网l问?也会Dq样的错?

要解册L错误,可以修改客户端的q接时讄.
默认情况?通过企业理器注册另外一台SQL Server的超时设|是 4 U?
而查询分析器?15 U(q也是ؓ什么在企业理器里发生错误的可能性比较大的原因).

具体步骤?
企业理器中的设|?
1.在企业管理器?选择菜单上的"工具",再选择"选项"
2.在弹出的"SQL Server企业理器属?H口?点击"高"选项?
3.?q接讄"下的"d时Q秒Q?双的框中输入一个比较大的数??20.

查询分析器中的设|?
工具 -- 选项 -- q接 -- 登录超时设|ؓ一个较大的数字


---------------------------------------------------------------------------------

?大部分机都用Tcp/ip才能成功Q有ơ我发现用Named Pipes才可以?

回复人: leimin(黄山光明?

q是因ؓ在WINDOWS 2000以后的操作系l中QMS决SQL SERVER的安全问题将TCP/IP配置
为SQLSERVER的默认连接协议,你可以在CLIENT NETWORK UTILITY中看到TCP/IP和NAME PIPE
的顺序?

你也可以在:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib]
"ProtocolOrder"=hex(7):74,00,63,00,70,00,00,00,00,00
看到默认的协议?

2.怎么在程序中更改Named Pipes Q?Tcp/ip Q其sql语句怎么写?
你可以在上面提到的注册表的位|修改:
CLIENT端:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib]
"ProtocolOrder"=hex(7):74,00,63,00,70,00,00,00,00,00

SERVER端:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib]
"ProtocolOrder"=hex(7):74,00,63,00,70,00,00,00,00,00

SQL?q接的配|就q两个方?

SQL Server服务?-开?-E序--Microsoft SQL Server
--服务器网l实用工?
--启用 WinSock代理
--代理地址:(sqlserver服务器IP)
--代理端口--1433
---定

客户?
开?-E序--Microsoft SQL Server--客户端网l实用工?
--别名--d
--|络库选择"tcp/ip"--服务器别名输入SQL服务器名
--q接参数--服务器名UC输入SQL服务器ip地址
--如果你修改了SQL的端?取消选择"动态决定端?,q输入对应的端口?

Titan 2006-02-16 23:17 发表评论
]]>
SQL语句优化技术分?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/Titan/articles/30381.html</guid><wfw:comment>http://www.aygfsteel.com/Titan/comments/30381.html</wfw:comment><comments>http://www.aygfsteel.com/Titan/articles/30381.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Titan/comments/commentRss/30381.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Titan/services/trackbacks/30381.html</trackback:ping><description><![CDATA[<div id="wmqeeuq" 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'">操作W优?/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'">操作W?/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'">的优Ҏ比较Ҏ写及清晰易懂Q这比较适合C软g开发的风格?/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'">性能L比较低的Q从</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">       </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'">里面的子查询Q再查询外层的表记录Q如果{换成功则直接采用多个表的q接方式查询。由此可见用</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'">臛_多了一个{换的q程。一般的</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'">都可以{换成功,但对于含有分l统计等斚w?/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">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐ҎQ在业务密集?/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'">操作W?/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'">操作W?/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">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此操作是强列推荐不用的Q因为它不能应用表的索引?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐ҎQ用</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'">判断为空Q方案代?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US><> </SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作W(不等于)</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">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不等于操作符是永q不会用到烦引的Q因此对它的处理只会产生全表扫描?/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'">推荐ҎQ用其它相同功能的操作运代替,?/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">       </SPAN>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> a>0 or a<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">       </SPAN>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> a>’?/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'">操作Q判断字D|否ؓI)</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">       </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">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">推荐ҎQ?/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'">用其它相同功能的操作q算代替Q如</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">       </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>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>’?/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">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不允许字DؓI,而用一个缺省g替空|如业扩申请中状态字D不允许为空Q缺省ؓ甌?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立位图索引Q有分区的表不能建,位图索引比较难控Ӟ如字D值太多烦引会使性能下降Q多人更新操作会增加数据块锁的现象)</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p> </o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN lang=EN-US>> </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> < </SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作W(大于或小于操作符Q?/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">       </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">大于或小于操作符一般情况下是不用调整的Q因为它有烦引就会采用烦引查找,但有的情况下可以对它q行优化Q如一个表?/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'">Q?/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'">Q?/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'">Q?/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'">Q?/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>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>=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>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'">的记录烦引再q行比较Q?/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>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> </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'">操作W?/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'">操作W可以应用通配W查询,里面的通配W组合可能达到几乎是L的查询,但是如果用得不好则会产生性能上的问题Q如</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'">q种查询不会引用索引Q?/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'">q个条g会生全表扫描,如果Ҏ</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'">的烦引进行两个范围的查询Q性能肯定大大提高?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><o:p> </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'">操作W?/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'">在进行表链接后会{选掉重复的记录,所以在表链接后会对所产生的结果集q行排序q算Q删除重复的记录再返回结果。实际大部分应用中是不会产生重复的记录,最常见的是q程表与历史?/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'">。如Q?/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'">q个</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'">在运行时先取Z个表的结果,再用排序I间q行排序删除重复的记录,最后返回结果集Q如果表数据量大的话可能会导致用盘q行排序?/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'">推荐ҎQ采?/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'">操作W替?/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'">Q因?/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'">操作只是单的两个结果合q后p回?/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> </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'">E序员写的ؓ</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">       </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'">E序员写的ؓ</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">       </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'">Q带表所有者的前缀Q?/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'">E序员写的ؓ</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">       </SPAN>Select * from DLYX.ZLYHJBQK</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q大写表名)</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'">E序员写的ؓ</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">       </SPAN>Select *<SPAN style="mso-spacerun: yes">  </SPAN>from DLYX.ZLYHJBQK</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q中间多了空|</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p> </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'">分析整理之后产生的结果及执行的时间是一LQ但是从</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'">׃n内存</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'">都会对其q行一ơ分析,q且占用׃n内存Q如果将</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'">的字W串及格式写得完全相同则</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'">只会分析一ơ,׃n内存也只会留下一ơ的分析l果Q这不仅可以减少分析</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'">的时_而且可以减少׃n内存重复的信息,</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> </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> </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'">子句后面的条仉序对大数据量表的查询会生直接的影响Q如</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">  </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">Q电压等U)?SPAN lang=EN-US>xh_bz</SPAN>Q销h志)两个字段都没q行索引Q所以执行的时候都是全表扫描,W一?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">条g在记录集内比率ؓ<SPAN lang=EN-US>99%</SPAN>Q?/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>Q在q行W一?SPAN lang=EN-US>SQL</SPAN>的时?SPAN lang=EN-US>99%</SPAN>条记录都q行</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">的比较,而在q行W二?SPAN lang=EN-US>SQL</SPAN>的时?SPAN lang=EN-US>0.5%</SPAN>条记录都q行</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">的比较,以此可以得出W二?SPAN lang=EN-US>SQL</SPAN>?SPAN lang=EN-US>CPU</SPAN>占用率明显比W一条低?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><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; 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'">执行性能影响Q在没有索引?/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'">没有对表q行l计分析的情况下</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'">会按表出现的序q行链接Q由此因的顺序不对会产生十分耗服务器资源的数据交叉。(注:如果对表q行了统计分析,</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'">会自动先q小表的链接Q再q行大表的链接)</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p> </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'">Ҏ件字D늚一些优?/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'">采用函数处理的字D不能利用烦引,如:</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'">Q优化处理:</SPAN><SPAN lang=EN-US>hbs_bh like ?400%?/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: 宋体">Q?优化处理Q?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>=trunc(<B>sysdate</B>) <B>and</B> sk_rq<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'">q行了显式或隐式的运的字段不能q行索引Q如Q?/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>50</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q优化处理:</SPAN><SPAN lang=EN-US>ss_df>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>’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'">Q优化处理:</SPAN><SPAN lang=EN-US>hbs_bh>?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'">Q优化处理:</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'">Q优化处理:</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'">Q?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'">q行隐式?/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'">转换Q因?/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'">字段是字W型?/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'">条g内包括了多个本表的字D运时不能q行索引Q如Q?/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>cx_df</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q无法进行优?/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'">Q优化处理:</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> </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'">Q提C)处理</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> </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'">q行以下斚w的提C?/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'">目标斚w的提C:</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'">Q按成本优化Q?/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'">Q按规则优化Q?/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'">Q缺省)Q?/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'">Q所有的行尽快返回)</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'">Q第一行数据尽快返回)</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'">执行Ҏ的提C:</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'">Q?/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'">方式联合Q?/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'">Q?/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'">方式联合Q?/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'">Q?/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'">方式联合Q?/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'">索引提示Q?/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'">Q?/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'">Q(使用提示的表索引q行查询Q?/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'">其它高提示Q如q行处理{等Q?/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> </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'">的提C功能是比较强的功能Q也是比较复杂的应用Qƈ且提C只是给</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'">执行的一个徏议,有时如果Z成本斚w的考虑</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'">也可能不会按提示q行。根据实践应用,一般不开发h员应?/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'">提示Q因为各个数据库及服务器性能情况不一P很可能一个地Ҏ能提升了,但另一个地方却下降了,</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'">执行分析斚w已经比较成熟Q如果分析执行的路径不对首先应在数据库结构(主要是烦引)、服务器当前性能Q共享内存、磁盘文件碎片)、数据库对象Q表、烦引)l计信息是否正确q几斚w分析?/SPAN></P></DIV><img src ="http://www.aygfsteel.com/Titan/aggbug/30381.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Titan/" target="_blank">Titan</a> 2006-02-12 22:05 <a href="http://www.aygfsteel.com/Titan/articles/30381.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]SQL语句大全 http://www.aygfsteel.com/Titan/articles/27200.htmlTitanTitanSun, 08 Jan 2006 17:57:00 GMThttp://www.aygfsteel.com/Titan/articles/27200.htmlhttp://www.aygfsteel.com/Titan/comments/27200.htmlhttp://www.aygfsteel.com/Titan/articles/27200.html#Feedback0http://www.aygfsteel.com/Titan/comments/commentRss/27200.htmlhttp://www.aygfsteel.com/Titan/services/trackbacks/27200.html阅读全文

Titan 2006-01-09 01:57 发表评论
]]>
վ֩ģ壺 | | ƴ| | | | | | | ɽ| н| | Ӵ| | | е| ־| | ֱ| | ɽ| | | ±| ʩ| ͤ| | | ˳| ϼ| ԭƽ| ɳ| Դ| տ| | | | | ʯ| ʯ| ƽ|