??xml version="1.0" encoding="utf-8" standalone="yes"?>BlogJava-Java世界http://www.qpkxbc.shop/rabbit/学习W记zh-cnSun, 25 Aug 2019 00:30:06 GMTSun, 25 Aug 2019 00:30:06 GMT60tips悬停http://www.qpkxbc.shop/rabbit/archive/2014/05/07/413378.htmlRabbitRabbitWed, 07 May 2014 14:23:00 GMThttp://www.qpkxbc.shop/rabbit/archive/2014/05/07/413378.htmlhttp://www.qpkxbc.shop/rabbit/comments/413378.htmlhttp://www.qpkxbc.shop/rabbit/archive/2014/05/07/413378.html#Feedback0http://www.qpkxbc.shop/rabbit/comments/commentRss/413378.htmlhttp://www.qpkxbc.shop/rabbit/services/trackbacks/413378.htmlhttp://www.php100.com/html/program/jquery/2013/0905/5970.html


http://vadikom.com/demos/poshytip/


http://www.cnblogs.com/best/archive/2011/09/27/2193572.html



JQuery插gTipsWindown 1.1

一个基于jQuery的弹出层。支持拖拽,支持内容为文字,囄QURL{?至于兼容性。在IE6下,弹出对像无法l对固定。其他应该没啥大问题Q?/p>

最新更斎ͼ(2010-08-12)Q修正IE6下不能遮住下拉菜单的BUGQ增加拖动时半透明效果?/p>

应用演示

  1. 弹出文本信息提示Q?
    tipsWindown("提示","text:提示信息内容","250","150","true","","true","msg")
  2. 弹出面中的某个ID的htmlQ?
    tipsWindown("标题","id:testID","300","200","true","","true","id")
  3. 弹出囄Q?
    tipsWindown("囄","img:囄路径","250","150","true","","true","img")
  4. get加蝲一?html文gQ也可以?php/.asp?id=4之类的)Q?
    tipsWindown("标题","url:get?test.html","250","150","true","","true","text");
  5. 加蝲一个页面到框架昄Q?br />
    tipsWindown("标题","iframe:http://www.nowamagic.net","900","580","true","","true","leotheme");
  6. 弹出一个不能拖动且没有遮罩背景的文本信息层Q?
    tipsWindown("提示","text:提示信息内容","250","150","false","","false","msg")
  7. 弹出一个不能拖动,三秒钟自动关闭的层:
    tipsWindown("提示","text:提示信息内容","250","150","false","3000","true","msg")

参数说明

参数 功能 备注
1 title 弹出层的标题 必填Q纯文本
2 content 弹出层的内容 text 文本内容
id 面里某id的子标签
img
url get或post某一面里的htmlQ该面要求只包含body的子标签
iframe 目标地址在框架显C?/td>
3 width 弹出层的?/td> 必填Q比?#8220;200”。(不需要带pxQ?/td>
4 height 弹出层的?/td> ?width
5 drag 是否可拖?/td> 必填Q可选参敎ͼtrue,falseQ?/td>
6 time 自动消失旉 可不填,默认不自动关闭;参数可ؓI?"")
7 showbg 是否昄遮罩?/td> 可不填,默认不显C(此项如填了,它前面的time也必要填)
8 cssName 弹出层附加样式名 可不?/td>

像这U弹出透明背景层效果很常见了,除部分区域可以操作外其他区域不能操作Q目前有提供插gQ完全可以实现此U效果?/p>

查看本页源代码可获取所有所需的代码?/p>

Rabbit 2014-05-07 22:23 发表评论
]]>
扚w插入QTestQ?/title><link>http://www.qpkxbc.shop/rabbit/archive/2014/04/15/412487.html</link><dc:creator>Rabbit</dc:creator><author>Rabbit</author><pubDate>Tue, 15 Apr 2014 13:38:00 GMT</pubDate><guid>http://www.qpkxbc.shop/rabbit/archive/2014/04/15/412487.html</guid><wfw:comment>http://www.qpkxbc.shop/rabbit/comments/412487.html</wfw:comment><comments>http://www.qpkxbc.shop/rabbit/archive/2014/04/15/412487.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.qpkxbc.shop/rabbit/comments/commentRss/412487.html</wfw:commentRss><trackback:ping>http://www.qpkxbc.shop/rabbit/services/trackbacks/412487.html</trackback:ping><description><![CDATA[<ol start="1" style="font-size: 12px; line-height: 1.4em; margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid #d1d7dc; list-style-position: initial; list-style-image: initial; background-color: #ffffff; color: #2b91af; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace;"><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;"><span style="color: #006699; font-weight: bold;"><</span><span style="color: #006699; font-weight: bold;">insert</span> <span style="color: red;">id</span>=<span style="color: blue;">"insertData"</span> <span style="color: red;">parameterType</span>=<span style="color: blue;">"java.util.List"</span> <span style="color: #006699; font-weight: bold;">></span>  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">        INSERT INTO EMP(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) (  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">        <span style="color: #006699; font-weight: bold;"><</span><span style="color: #006699; font-weight: bold;">foreach</span> <span style="color: red;">collection</span>=<span style="color: blue;">"list"</span> <span style="color: red;">item</span>=<span style="color: blue;">"item"</span> <span style="color: red;">index</span>=<span style="color: blue;">"index"</span> <span style="color: red;">separator</span>=<span style="color: blue;">"union all"</span><span style="color: #006699; font-weight: bold;">></span>  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">            select  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">                #{item.EMPNO,<span style="color: red;">jdbcType</span>=<span style="color: blue;">VARCHAR</span>},  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">                #{item.ENAME,<span style="color: red;">jdbcType</span>=<span style="color: blue;">VARCHAR</span>},  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">                #{item.JOB,<span style="color: red;">jdbcType</span>=<span style="color: blue;">VARCHAR</span>},  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">                #{item.MGR,<span style="color: red;">jdbcType</span>=<span style="color: blue;">NUMERIC</span>},  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">                #{item.MGR,<span style="color: red;">jdbcType</span>=<span style="color: blue;">NUMERIC</span>},  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">                TO_DATE(#{item.HIREDATE,<span style="color: red;">jdbcType</span>=<span style="color: blue;">VARCHAR</span>},'yyyy-mm-dd')  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">                  from dual  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">        <span style="color: #006699; font-weight: bold;"></</span><span style="color: #006699; font-weight: bold;">foreach</span><span style="color: #006699; font-weight: bold;">></span>  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;">        )  </span></li><li style="font-size: 1em; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;"><span style="color: black;"><span style="color: #006699; font-weight: bold;"></</span><span style="color: #006699; font-weight: bold;">insert</span><span style="color: #006699; font-weight: bold;">></span> <br /><br />=====================================================================<br /><br /><br /><div>declare    </div><div>  type t_array is table of t_target%rowtype;    </div><div>  t_data t_array;    </div><div>  cursor c is    </div><div>    select null id, owner, object_name, null object_id, null xx, null yy    </div><div>    from dba_objects;    </div><div>begin    </div><div>  open c;    </div><div>  loop    </div><div>    fetch c bulk collect    </div><div>    into t_data limit 100;    </div><div>    </div><div>    forall i in 1 .. t_data.count    </div><div>      insert into t_target values t_data (i);    </div><div>    exit when c%notfound;    </div><div>  end loop;    </div><div>  close c;    </div><div>  commit;    </div><div>end; <br /><br /><br /><br /><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; color: #333333; line-height: 21px; font-family: 'Courier New' !important;"><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: #800000; line-height: 1.5 !important;">insert </span><span style="margin: 0px; padding: 0px; color: #ff0000; line-height: 1.5 !important;">id</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">="insertByProc"</span><span style="margin: 0px; padding: 0px; color: #ff0000; line-height: 1.5 !important;"> statementType</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">="CALLABLE"</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">></span> <span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;"> <br />{call insertPro(#{name},#{age},#{sex},#{password},#{num})} </span> <br /><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: #800000; line-height: 1.5 !important;">insert</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">><br /><br /><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; color: #333333; line-height: 21px; font-family: 'Courier New' !important;"><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;">1</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">CREATE</span> DEFINER <span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">=</span> `root`@`localhost` <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">PROCEDURE</span> `NewProc`(<span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">IN</span> `name_in` <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">varchar</span>(<span style="margin: 0px; padding: 0px; color: #800000; font-weight: bold; line-height: 1.5 !important;">255</span>),<span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">IN</span> `age_in` <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">int</span>,<span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">IN</span> `sex_in` <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">varchar</span>(<span style="margin: 0px; padding: 0px; color: #800000; font-weight: bold; line-height: 1.5 !important;">255</span>),<span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">IN</span> `password_in` <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">varchar</span>(<span style="margin: 0px; padding: 0px; color: #800000; font-weight: bold; line-height: 1.5 !important;">255</span>),<span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">IN</span> `num_in` <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">int</span><span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;">) </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 2</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">BEGIN</span> <span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 3</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">SET</span> <span style="margin: 0px; padding: 0px; color: #008000; line-height: 1.5 !important;">@a</span><span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">=</span><span style="margin: 0px; padding: 0px; color: #800000; font-weight: bold; line-height: 1.5 !important;">0</span><span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;">; </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 4</span> <span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;">Label:LOOP </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 5</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">SET</span> <span style="margin: 0px; padding: 0px; color: #008000; line-height: 1.5 !important;">@a</span><span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">=</span><span style="margin: 0px; padding: 0px; color: #008000; line-height: 1.5 !important;">@a</span><span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">+</span><span style="margin: 0px; padding: 0px; color: #800000; font-weight: bold; line-height: 1.5 !important;">1</span><span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;">; </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 6</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">INSERT</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">INTO</span> person ( name, age, sex, password) <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">VALUES</span><span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;"> (name_in,age_in,sex_in,password_in); </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 7</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">IF</span> <span style="margin: 0px; padding: 0px; color: #008000; line-height: 1.5 !important;">@a</span><span style="margin: 0px; padding: 0px; color: #808080; line-height: 1.5 !important;">=</span>num_in <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">THEN</span> <span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 8</span> <span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;"> LEAVE Label; </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;"> 9</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">END</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">IF</span><span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;">; </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;">10</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">END</span><span style="margin: 0px; padding: 0px; color: #000000; line-height: 1.5 !important;"> LOOP Label; </span><span style="margin: 0px; padding: 0px; color: #008080; line-height: 1.5 !important;">11</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">END</span>;</pre></span></pre></div><br /></span></li></ol><img src ="http://www.qpkxbc.shop/rabbit/aggbug/412487.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.qpkxbc.shop/rabbit/" target="_blank">Rabbit</a> 2014-04-15 21:38 <a href="http://www.qpkxbc.shop/rabbit/archive/2014/04/15/412487.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle中Hint深入理解http://www.qpkxbc.shop/rabbit/archive/2013/11/08/406141.htmlRabbitRabbitFri, 08 Nov 2013 06:44:00 GMThttp://www.qpkxbc.shop/rabbit/archive/2013/11/08/406141.htmlhttp://www.qpkxbc.shop/rabbit/comments/406141.htmlhttp://www.qpkxbc.shop/rabbit/archive/2013/11/08/406141.html#Feedback0http://www.qpkxbc.shop/rabbit/comments/commentRss/406141.htmlhttp://www.qpkxbc.shop/rabbit/services/trackbacks/406141.htmlHint概述
Z代h的优化器是很聪明的,在绝大多数情况下它会选择正确的优化器Q减MDBA的负担。但有时它也聪明反被聪明误,选择了很差的执行计划Q某个语句的执行变得奇慢无比?/font>

此时需要DBAq行Zؓ的干预,告诉优化器用我们指定的存取路径或连接类型生成执行计划,从而语句高效的运行。例如,如果我们认ؓ对于一个特定的语句Q执行全表扫描要比执行烦引扫描更有效Q则我们可以指CZ化器使用全表扫描。在Oracle 中,是通过句添?Hints(提示)来实现干预优化器优化的目的?br />不徏议在代码中用hintQ在代码使用hint使得CBO无法Ҏ实际的数据状态选择正确的执行计划。毕?/font> 数据是不断变化的Q?/font> 10g以后的CBO也越来越完善Q大多数情况下我们该让Oracle自行军_采用什么执行计划?/font>

Oracle Hints是一U机Ӟ用来告诉优化器按照我们的告诉它的方式生成执行计划。我们可以用Oracle Hints来实玎ͼ
1) 使用的优化器的类?br />2) Z代h的优化器的优化目标,是all_rowsq是first_rows?br />3) 表的讉K路径Q是全表扫描Q还是烦引扫描,q是直接利用rowid?br />4) 表之间的q接cd
5) 表之间的q接序
6) 语句的ƈ行程?/font>

除了”RULE”提示外,一旦用的别的提示Q语句就会自动的改ؓ使用CBO优化器,此时如果你的数据字典中没有统计数据,׃使用~省的统计数据。所以徏议大家如果用CBO或Hints提示Q则最好对表和索引q行定期的分析?/font>

如何使用Hints:

Hints只应用在它们所在sql语句?statement blockQ由select、update、delete关键字标?上,对其它SQL语句或语句的其它部分没有影响。如Q对于用union操作?个sql语句Q如果只在一个sql语句上有HintsQ则该Hints不会影响另一个sql语句?/font>

我们可以使用注释(comment)来ؓ一个语句添加HintsQ一个语句块只能有一个注释,而且注释只能攑֜SELECT, UPDATE, or DELETE关键字的后面

使用Oracle Hints的语法:

{DELETE|INSERT|SELECT|UPDATE} /*+ hint [text] [hint[text]]... */

or

{DELETE|INSERT|SELECT|UPDATE} --+ hint [text] [hint[text]]...

注解Q?br />1) DELETE、INSERT、SELECT和UPDATE是标识一个语句块开始的关键字,包含提示的注释只能出现在q些关键字的后面Q否则提C无效?br />2) “+”可C注释是一个HintsQ该加号必须立即跟在”/*”的后面,中间不能有空根{?br />3) hint是下面介l的具体提示之一Q如果包含多个提C,则每个提CZ间需要用一个或多个I格隔开?br />4) text 是其它说明hint的注释性文?/font>

5)使用表别名。如果在查询中指定了表别名,那么提示必须也用表别名。例如:select /*+ index(e,dept_idx) */ * from emp e;
6)不要在提CZ使用模式名称Q如果在提示中指定了模式的所有者,那么提示被忽略。例如:
select /*+ index(scott.emp,dept_idx) */ * from emp

注意Q如果你没有正确的指定HintsQOracle忽略该HintsQƈ且不会给ZQ何错误?br />hint被忽?/strong>

如果CBO认ؓ使用hint会导致错误的l果Ӟhint被忽略Q详见下?br />SQL> select /*+ index(t t_ind) */ count(*) from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 2966233522
-------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Cost (%CPU)| Time     |
-------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |    57   (2)| 00:00:01 |
|   1 |  SORT AGGREGATE    |      |     1 |            |          |
|   2 |   TABLE ACCESS FULL| T    | 50366 |    57   (2)| 00:00:01 |
-------------------------------------------------------------------

因ؓ我们是对记录求LQ且我们q没有在建立索引时指定不能ؓI,索引如果CBO选择在烦引上q行countӞ但烦引字D上的gؓI时Q结果将不准,故CBO没有选择索引?/font>
SQL>  select /*+ index(t t_ind) */ count(id) from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 646498162
--------------------------------------------------------------------------
| Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT |       |     1 |     5 |   285   (1)| 00:00:04 |
|   1 |  SORT AGGREGATE  |       |     1 |     5 |            |          |
|   2 |   INDEX FULL SCAN| T_IND | 50366 |   245K|   285   (1)| 00:00:04 |
--------------------------------------------------------------------------

因ؓ我们只对idq行countQ这个动作相当于count索引上的所有id|q个操作和对表上的id字段q行count是一L(l函C忽略null?

Hint的具体用?br />

和优化器相关的hint

1?*+ ALL_ROWS */
表明对语句块选择Z开销的优化方?q获得最佛_吐量,使资源消耗最化.
SELECT /*+ ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO='SCOTT';

2?*+ FIRST_ROWS(n) */
表明对语句块选择Z开销的优化方?q获得最佛_应时?使资源消耗最化.
SELECT /*+FIRST_ROWS(20) */ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO='SCOTT';
3?*+ RULE*/
表明对语句块选择Z规则的优化方?
SELECT /*+ RULE */ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO='SCOTT';
和访问\径相关的hint

1?*+ FULL(TABLE)*/
表明对表选择全局扫描的方?
SELECT /*+FULL(A)*/ EMP_NO,EMP_NAM FROM BSEMPMS A WHERE EMP_NO='SCOTT';

2?*+ INDEX(TABLE INDEX_NAME) */
表明对表选择索引的扫描方?
SELECT /*+INDEX(BSEMPMS SEX_INDEX) */ * FROM BSEMPMS WHERE SEX='M';
5?*+ INDEX_ASC(TABLE INDEX_NAME)*/
表明对表选择索引升序的扫描方?
SELECT /*+INDEX_ASC(BSEMPMS PK_BSEMPMS) */ * FROM BSEMPMS WHERE DPT_NO='SCOTT';
6?*+ INDEX_COMBINE*/
为指定表选择位图讉K路经,如果INDEX_COMBINE中没有提供作为参数的索引,选择Z囄引的布尔l合方式.
SELECT /*+INDEX_COMBINE(BSEMPMS SAL_BMI HIREDATE_BMI) */  * FROM BSEMPMS
WHERE SAL<5000000 AND HIREDATE

7?*+ INDEX_JOIN(TABLE INDEX_NAME1 INDEX_NAME2) */
当谓词中引用的列都有索引的时候,可以通过指定采用索引兌的方式,来访问数?br />
select /*+ index_join(t t_ind t_bm) */ id from t where id=100 and object_name='EMPLOYEES'
8?*+ INDEX_DESC(TABLE INDEX_NAME)*/
表明对表选择索引降序的扫描方?

SELECT /*+INDEX_DESC(BSEMPMS PK_BSEMPMS) */ * FROM BSEMPMS WHERE DPT_NO='SCOTT';
9?*+ INDEX_FFS(TABLE INDEX_NAME) */
Ҏ定的表执行快速全索引扫描,而不是全表扫描的办法.
SELECT /* + INDEX_FFS(BSEMPMS IN_EMPNAM)*/ * FROM BSEMPMS WHERE DPT_NO='TEC305';

10?*+ INDEX_SS(T T_IND) */
?i开始,oracle引入了这U烦引访问方式。当在一个联合烦引中Q某些谓词条件ƈ不在联合索引的第一列时Q可以通过Index Skip Scan来访问烦引获得数据。当联合索引W一列的唯一g数很时Q用这U方式比全表扫描效率高?/font>

SQL> create table t as select 1 id,object_name from dba_objects;
Table created.
SQL> insert into t select 2,object_name from dba_objects;      
50366 rows created.
SQL> insert into t select 3,object_name from dba_objects;      
50366 rows created.

SQL> insert into t select 4,object_name from dba_objects;      
50366 rows created.

SQL> commit;
Commit complete.
SQL> create index t_ind on t(id,object_name);
Index created.
SQL> exec dbms_stats.gather_table_stats('HR','T',cascade=>true);
PL/SQL procedure successfully completed.
执行全表扫描
SQL> select /*+ full(t) */ * from t where object_name='EMPLOYEES';
6 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     5 |   135 |   215   (3)| 00:00:03 |
|*  1 |  TABLE ACCESS FULL| T    |     5 |   135 |   215   (3)| 00:00:03 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("OBJECT_NAME"='EMPLOYEES')
Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
        942  consistent gets
          0  physical reads
          0  redo size
        538  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          6  rows processed
不采用hint
SQL>  select * from t where object_name='EMPLOYEES';
6 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2869677071
--------------------------------------------------------------------------
| Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT |       |     5 |   135 |     5   (0)| 00:00:01 |
|*  1 |  INDEX SKIP SCAN | T_IND |     5 |   135 |     5   (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("OBJECT_NAME"='EMPLOYEES')
       filter("OBJECT_NAME"='EMPLOYEES')
Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
         17  consistent gets
          1  physical reads
          0  redo size
        538  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          6  rows processed

当全表扫描扫描了942个块Q联合烦引只扫描?7个数据块。可以看到联合烦引的W一个字D늚值重复率很高Ӟ即谓词中没有联合烦引的W一个字D,依然会用index_ss方式Q效率远q高于全表扫描效率。但?/font>
W一个字D늚值重复率很低Ӟ使用 index_ss的效率要低于 全表扫描Q读者可以自行实?/font>
和表的关联相关的hint

/*+ leading(table_1,table_2) */

在多表关联查询中Q指定哪个表作ؓ驱动表,卛_诉优化器首先要访问哪个表上的数据?/span>
select /*+ leading(t,t1) */ t.* from t,t1 where t.id=t1.id;

/*+ order */

让OracleҎfrom后面表的序来选择驱动表,oracle使用leadingQ他更ؓ灉|
select /*+ order */ t.* from t,t1 where t.id=t1.id;
/*+ use_nl(table_1,table_2) */
在多表关联查询中Q指定用nest loops方式q行多表兌?/span>

select /*+ use_nl(t,t1) */ t.* from t,t1 where t.id=t1.id;

/*+ use_hash(table_1,table_2) */
在多表关联查询中Q指定用hash join方式q行多表兌?/span>

select /*+ use_hash(t,t1) */ t.* from t,t1 where t.id=t1.id;

在多表关联查询中Q指定用hash join方式q行多表兌Qƈ指定表t为驱动表?/font>

select /*+ use_hash(t,t1) leading(t,t1) */ t.* from t,t1 where t.id=t1.id;

/*+ use_merge(table_1,table_2) */
在多表关联查询中Q指定用merge join方式q行多表兌?/span>

select /*+ use_merge(t,t1) */ t.* from t,t1 where t.id=t1.id;

/*+ no_use_nl(table_1,table_2) */
在多表关联查询中Q指定不使用nest loops方式q行多表兌?/span>

select /*+ no_use_nl(t,t1) */ t.* from t,t1 where t.id=t1.id;

/*+ no_use_hash(table_1,table_2) */
在多表关联查询中Q指定不使用hash join方式q行多表兌?/span>

select /*+ no_use_hash(t,t1) */ t.* from t,t1 where t.id=t1.id;

/*+ no_use_merge(table_1,table_2) */
在多表关联查询中Q指定不使用merge join方式q行多表兌?/span>

select /*+ no_use_merge(t,t1) */ t.* from t,t1 where t.id=t1.id;

其他常用的hint

/*+ parallel(table_name n) */

在sql中指定执行的q行度,q个值将会覆盖自w的q行?br />

select /*+ parallel(t 4) */ count(*)  from t;

/*+ no_parallel(table_name) */

在sql中指定执行的不用ƈ?br />

select /*+ no_parallel(t) */ count(*)  from t;

/*+ append */以直接加载的方式数据加载入?

insert into t /*+ append */ select * from t;

/*+ dynamic_sampling(table_name n) */

讄sql执行时动态采用的U别Q这个别ؓ0~10
select /*+ dynamic_sampling(t 4) */ * from t where id > 1234

/*+ cache(table_name) */
q行全表扫描时将table|于LRU列表的最z跃端,cM于table的cache属?br />

select /*+ full(employees) cache(employees) */ last_name from employees
附录hint表格

Hints for Optimization Approaches and Goals

ALL_ROWS The ALL_ROWS hint explicitly chooses the cost-based approach to optimize a statement block with a goal of best throughput (that is, minimum total resource consumption).
FIRST_ROWS The FIRST_ROWS hint explicitly chooses the cost-based approach to optimize a statement block with a goal of best response time (minimum resource usage to return first row). In newer Oracle version you should give a parameter with this hint: FIRST_ROWS(n) means that the optimizer will determine an executionplan to give a fast response for returning the first n rows.
CHOOSE The CHOOSE hint causes the optimizer to choose between the rule-based approach and the cost-based approach for a SQL statement based on the presence of statistics for the tables accessed by the statement
RULE The RULE hint explicitly chooses rule-based optimization for a statement block. This hint also causes the optimizer to ignore any other hints specified for the statement block. The RULE hint does not work any more in Oracle 10g.

Hints for Access Paths

FULL The FULL hint explicitly chooses a full table scan for the specified table. The syntax of the FULL hint is FULL(table) where table specifies the alias of the table (or table name if alias does not exist) on which the full table scan is to be performed.
ROWID The ROWID hint explicitly chooses a table scan by ROWID for the specified table. The syntax of the ROWID hint is ROWID(table) where table specifies the name or alias of the table on which the table access by ROWID is to be performed. (This hint depricated in Oracle 10g)
CLUSTER The CLUSTER hint explicitly chooses a cluster scan to access the specified table. The syntax of the CLUSTER hint is CLUSTER(table) where table specifies the name or alias of the table to be accessed by a cluster scan.
HASH The HASH hint explicitly chooses a hash scan to access the specified table. The syntax of the HASH hint is HASH(table) where table specifies the name or alias of the table to be accessed by a hash scan.
HASH_AJ The HASH_AJ hint transforms a NOT IN subquery into a hash anti-join to access the specified table. The syntax of the HASH_AJ hint is HASH_AJ(table) where table specifies the name or alias of the table to be accessed.(depricated in Oracle 10g)
INDEX The INDEX hint explicitly chooses an index scan for the specified table. The syntax of the INDEX hint is INDEX(table index) where:table specifies the name or alias of the table associated with the index to be scanned and index specifies an index on which an index scan is to be performed. This hint may optionally specify one or more indexes:
NO_INDEX The NO_INDEX hint explicitly disallows a set of indexes for the specified table. The syntax of the NO_INDEX hint is NO_INDEX(table index)
INDEX_ASC The INDEX_ASC hint explicitly chooses an index scan for the specified table. If the statement uses an index range scan, Oracle scans the index entries in ascending order of their indexed values.
INDEX_COMBINE If no indexes are given as arguments for the INDEX_COMBINE hint, the optimizer will use on the table whatever boolean combination of bitmap indexes has the best cost estimate. If certain indexes are given as arguments, the optimizer will try to use some boolean combination of those particular bitmap indexes. The syntax of INDEX_COMBINE is INDEX_COMBINE(table index).
INDEX_JOIN Explicitly instructs the optimizer to use an index join as an access path. For the hint to have a positive effect, a sufficiently small number of indexes must exist that contain all the columns required to resolve the query.
INDEX_DESC The INDEX_DESC hint explicitly chooses an index scan for the specified table. If the statement uses an index range scan, Oracle scans the index entries in descending order of their indexed values.
INDEX_FFS This hint causes a fast full index scan to be performed rather than a full table.
NO_INDEX_FFS Do not use fast full index scan (from Oracle 10g)
INDEX_SS Exclude range scan from query plan (from Oracle 10g)
INDEX_SS_ASC Exclude range scan from query plan (from Oracle 10g)
INDEX_SS_DESC Exclude range scan from query plan (from Oracle 10g)
NO_INDEX_SS The NO_INDEX_SS hint causes the optimizer to exclude a skip scan of the specified indexes on the specified table. (from Oracle 10g)

Hints for Query Transformations

NO_QUERY_TRANSFORMATION Prevents the optimizer performing query transformations. (from Oracle 10g)
USE_CONCAT The USE_CONCAT hint forces combined OR conditions in the WHERE clause of a query to be transformed into a compound query using the UNION ALL set operator. Normally, this transformation occurs only if the cost of the query using the concatenations is cheaper than the cost without them.
NO_EXPAND The NO_EXPAND hint prevents the optimizer from considering OR-expansion for queries having OR conditions or IN-lists in the WHERE clause. Usually, the optimizer considers using OR expansion and uses this method if it decides that the cost is lower than not using it.
REWRITE The REWRITE hint forces the optimizer to rewrite a query in terms of materialized views, when possible, without cost consideration. Use the REWRITE hint with or without a view list. If you use REWRITE with a view list and the list contains an eligible materialized view, then Oracle uses that view regardless of its cost.
NOREWRITE / NO_REWRITE In Oracle 10g renamed to NO_REWRITE. The NOREWRITE/NO_REWRITE hint disables query rewrite for the query block, overriding the setting of the parameter QUERY_REWRITE_ENABLED.
MERGE The MERGE hint lets you merge views in a query.
NO_MERGE The NO_MERGE hint causes Oracle not to merge mergeable views. This hint is most often used to reduce the number of possible permutations for a query and make optimization faster.
FACT The FACT hint indicated that the table should be considered as a fact table. This is used in the context of the star transformation.
NO_FACT The NO_FACT hint is used in the context of the star transformation to indicate to the transformation that the hinted table should not be considered as a fact table.
STAR_TRANSFORMATION The STAR_TRANSFORMATION hint makes the optimizer use the best plan in which the transformation has been used. Without the hint, the optimizer could make a query optimization decision to use the best plan generated without the transformation, instead of the best plan for the transformed query.
NO_STAR_TRANSFORMATION Do not use star transformation (from Oracle 10g)
UNNEST The UNNEST hint specifies subquery unnesting.
NO_UNNEST Use of the NO_UNNEST hint turns off unnesting for specific subquery blocks.

Hints for Join Orders

LEADING Give this hint to indicate the leading table in a join. This will indicate only 1 table. If you want to specify the whole order of tables, you can use the ORDERED hint. Syntax: LEADING(table)
ORDERED The ORDERED hint causes Oracle to join tables in the order in which they appear in the FROM clause. If you omit the ORDERED hint from a SQL statement performing a join , the optimizer chooses the order in which to join the tables. You may want to use the ORDERED hint to specify a join order if you know something about the number of rows selected from each table that the optimizer does not. Such information would allow you to choose an inner and outer table better than the optimizer could.

Hints for Join Operations

USE_NL The USE_NL hint causes Oracle to join each specified table to another row source with a nested loops join using the specified table as the inner table. The syntax of the USE_NL hint is USE_NL(table table) where table is the name or alias of a table to be used as the inner table of a nested loops join.
NO_USE_NL Do not use nested loop (from Oracle 10g)
USE_NL_WITH_INDEX Specifies a nested loops join. (from Oracle 10g)
USE_MERGE The USE_MERGE hint causes Oracle to join each specified table with another row source with a sort-merge join. The syntax of the USE_MERGE hint is USE_MERGE(table table) where table is a table to be joined to the row source resulting from joining the previous tables in the join order using a sort-merge join.
NO_USE_MERGE Do not use merge (from Oracle 10g)
USE_HASH The USE_HASH hint causes Oracle to join each specified table with another row source with a hash join. The syntax of the USE_HASH hint is USE_HASH(table table) where table is a table to be joined to the row source resulting from joining the previous tables in the join order using a hash join.
NO_USE_HASH Do not use hash (from Oracle 10g)
Hints for Parallel Execution
PARALLEL The PARALLEL hint allows you to specify the desired number of concurrent query servers that can be used for the query. The syntax is PARALLEL(table number number). The PARALLEL hint must use the table alias if an alias is specified in the query. The PARALLEL hint can then take two values separated by commas after the table name. The first value specifies the degree of parallelism for the given table, the second value specifies how the table is to be split among the instances of a parallel server. Specifying DEFAULT or no value signifies the query coordinator should examine the settings of the initialization parameters (described in a later section) to determine the default degree of parallelism.
NOPARALLEL / NO_PARALLEL The NOPARALLEL hint allows you to disable parallel scanning of a table, even if the table was created with a PARALLEL clause. In Oracle 10g this hint was renamed to NO_PARALLEL.
PQ_DISTRIBUTE The PQ_DISTRIBUTE hint improves the performance of parallel join operations. Do this by specifying how rows of joined tables should be distributed among producer and consumer query servers. Using this hint overrides decisions the optimizer would normally make.
NO_PARALLEL_INDEX The NO_PARALLEL_INDEX hint overrides a PARALLEL attribute setting on an index to avoid a parallel index scan operation.
Additional Hints
APPEND When the APPEND hint is used with the INSERT statement, data is appended to the table. Existing free space in the block is not used. If a table or an index is specified with nologging, this hint applied with an insert statement produces a direct path insert which reduces generation of redo.
NOAPPEND Overrides the append mode.
CACHE The CACHE hint specifies that the blocks retrieved for the table in the hint are placed at the most recently used end of the LRU list in the buffer cache when a full table scan is performed. This option is useful for small lookup tables. In the following example, the CACHE hint overrides the table default caching specification.
NOCACHE The NOCACHE hint specifies that the blocks retrieved for this table are placed at the least recently used end of the LRU list in the buffer cache when a full table scan is performed. This is the normal behavior of blocks in the buffer cache.
PUSH_PRED The PUSH_PRED hint forces pushing of a join predicate into the view.
NO_PUSH_PRED The NO_PUSH_PRED hint prevents pushing of a join predicate into the view.
PUSH_SUBQ The PUSH_SUBQ hint causes nonmerged subqueries to be evaluated at the earliest possible place in the execution plan.
NO_PUSH_SUBQ The NO_PUSH_SUBQ hint causes non-merged subqueries to be evaluated as the last step in the execution plan.
QB_NAME Specifies a name for a query block. (from Oracle 10g)
CURSOR_SHARING_EXACT Oracle can replace literals in SQL statements with bind variables, if it is safe to do so. This is controlled with the CURSOR_SHARING startup parameter. The CURSOR_SHARING_EXACT hint causes this behavior to be switched off. In other words, Oracle executes the SQL statement without any attempt to replace literals by bind variables.
DRIVING_SITE The DRIVING_SITE hint forces query execution to be done for the table at a different site than that selected by Oracle
DYNAMIC_SAMPLING The DYNAMIC_SAMPLING hint lets you control dynamic sampling to improve server performance by determining more accurate predicate selectivity and statistics for tables and indexes. You can set the value of DYNAMIC_SAMPLING to a value from 0 to 10. The higher the level, the more effort the compiler puts into dynamic sampling and the more broadly it is applied. Sampling defaults to cursor level unless you specify a table.
SPREAD_MIN_ANALYSIS This hint omits some of the compile time optimizations of the rules, mainly detailed dependency graph analysis, on spreadsheets. Some optimizations such as creating filters to selectively populate spreadsheet access structures and limited rule pruning are still used. (from Oracle 10g)

Hints with unknown status

MERGE_AJ The MERGE_AJ hint transforms a NOT IN subquery into a merge anti-join to access the specified table. The syntax of the MERGE_AJ hint is MERGE_AJ(table) where table specifies the name or alias of the table to be accessed.(depricated in Oracle 10g)
AND_EQUAL The AND_EQUAL hint explicitly chooses an execution plan that uses an access path that merges the scans on several single-column indexes. The syntax of the AND_EQUAL hint is AND_EQUAL(table index index) where table specifies the name or alias of the table associated with the indexes to be merged. and index specifies an index on which an index scan is to be performed. You must specify at least two indexes. You cannot specify more than five. (depricated in Oracle 10g)
STAR The STAR hint forces the large table to be joined last using a nested loops join on the index. The optimizer will consider different permutations of the small tables. (depricated in Oracle 10g)
BITMAP Usage: BITMAP(table_name index_name) Uses a bitmap index to access the table. (depricated ?)
HASH_SJ
Use a Hash Anti-Join to evaluate a NOT IN sub-query. Use this hint in the sub-query, not in the main query. Use this when your high volume NOT IN sub-query is using a FILTER or NESTED LOOPS join. Try MERGE_AJ if HASH_AJ refuses to work.(depricated in Oracle 10g)
NL_SJ Use a Nested Loop in a sub-query. (depricated in Oracle 10g)
NL_AJ Use an anti-join in a sub-query. (depricated in Oracle 10g)
ORDERED_PREDICATES (depricated in Oracle 10g)
EXPAND_GSET_TO_UNION (depricated in Oracle 10g)


参考至Q《让Oracle跑得更快》K怀q著



Rabbit 2013-11-08 14:44 发表评论
]]>
oracle table-lock?U模?/title><link>http://www.qpkxbc.shop/rabbit/archive/2013/11/05/406007.html</link><dc:creator>Rabbit</dc:creator><author>Rabbit</author><pubDate>Tue, 05 Nov 2013 06:31:00 GMT</pubDate><guid>http://www.qpkxbc.shop/rabbit/archive/2013/11/05/406007.html</guid><wfw:comment>http://www.qpkxbc.shop/rabbit/comments/406007.html</wfw:comment><comments>http://www.qpkxbc.shop/rabbit/archive/2013/11/05/406007.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.qpkxbc.shop/rabbit/comments/commentRss/406007.html</wfw:commentRss><trackback:ping>http://www.qpkxbc.shop/rabbit/services/trackbacks/406007.html</trackback:ping><description><![CDATA[<span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; font-weight: bold;">Oracle中的锁定可以分ؓ几类Q?/span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">1、DML lockQdata lockQ,</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">2、DDL lockQdictionary lock)</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">3、internal lock/latch?/span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">DML lock又可以分为row lock和table lock。row lock在select.. for update/insert/update/delete旉式自动生,而table lock除了隐式产生Q也可以调用lock table <table_name> in </table_name> name来显C锁定?/span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">如果不希望别的session lock/insert/update/delete表中L一行,只允许查询,可以用lock table table_name in exclusive mode?X)q个锁定模式U别最高,q发度最?/span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">如果允许别的session查询或用select for update锁定记录Q不允许insert/update/deleteQ可以用</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; color: red;">lock table table_name in share row exclusive mode?SRX)</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">如果允许别的session查询或select for update以及lock table table_name in share modeQ只是不允许insert/update/deleteQ可以用</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">lock table table_name in share mode?share mode和share row exclusive mode的区别在于一个是非抢占式的而另一个是抢占式的。进入share row exclusive mode后其他session不能L你insert/update/deleteQ而进入share mode后其他session也同样可以进入share modeQ进而阻止你对表的修攏V?S)</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">q有两种锁定模式Qrow share(RS)和row exclusive(RX)。他们允许的q发操作更多Q一般直接用DML语句自动获得Q而不用lock语句?/span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">详细参考concepts文档中的"Type Of Locks"Q?/span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96524/c21cnsis.htm#2937 </span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">-------------------------------------</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="font-weight: bold;">怎么unlock table 解锁</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; font-weight: bold;">Ҏ一、kill sessionQ?/span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">SQL> select object_id,session_id from v$locked_object;  //注意session_id 是上锁?session标志</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">SQL> select username,sid,SERIAL#  from v$session where sid=。?      //q里的SID = session_id </span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff;">SQL> alter system kill session 'id,serial#';     //杀死该session</span><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><br style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;" /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; font-weight: bold;">Ҏ二、rollback/commit l止事务处理<br /><br /><br /></span><a href="http://blog.chinaunix.net/uid-8504518-id-3436965.html" style="word-wrap: break-word; color: #19599b; font-family: 微Y雅黑, 黑体, Verdana; font-size: 20px; background-color: #ffffff;">ORACLE 大表建立索引的一些考虑</a><span style="color: #565656; font-family: 宋体, Arial; font-size: 12px; line-height: 12px; background-color: #ffffff;"> </span><br /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; font-weight: bold;"><br /></span><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">首先Q?/span><strong style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">应当考虑表空间和盘I间是否_</strong><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">。我们知道烦引也是一U数据,在徏立烦引的时候势必也会占用大量表I间。因此在对一张大表徏立烦引的时候首先应当考虑的是I间定w问题?/span><br style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;" /><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">其次Q在对徏立烦引的时候要对表q行加锁Q因此应当注?/span><strong style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">操作在业务空闲的时候进?/strong><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">?/span><br style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;" /><strong style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;"><em style="word-wrap: break-word;">性能调整ҎQ?/em></strong><br style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;" /><font color="#0000F0" style="word-wrap: break-word; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">首先应考虑IOQ?物理上,应当量把烦引与数据分散C同的盘上?逻辑上,数据表空间与索引表空间分开。这是在建烦引时应当守的基本原?/font><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">?/span><br style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;" /><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">其次Q?/span><font color="#0000F0" style="word-wrap: break-word; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">在徏立烦引的时候要对表q行全表的扫描工?/font><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">Q因此,应当考虑调大初始化参?/span><font color="#0000F0" style="word-wrap: break-word; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">db_file_multiblock_read_count的倹{一般设|ؓ16或更?/font><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">?/span><br style="word-wrap: break-word; color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;" /><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">?ơ,</span><font color="#0000F0" style="word-wrap: break-word; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">建立索引除了要进行全表扫描外同时q要Ҏ据进行大量的排序操作</font><span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">Q因此,应当调整排序区的大小。在9I之前Q?可以在SESSIONU别上加大sort_area_size 的大, 比如讄?00M或者更大?I 以后Q?如果</span><font color="#0000F0" style="word-wrap: break-word; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">初始化参数workarea_size_policy的gؓTRUEQ?则排序区从PGA_AGGREGATE_TARGET里自动分配获?/font><br /><span style="color: #4b4b4b; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; font-weight: bold;"><br /><br /></span><img src ="http://www.qpkxbc.shop/rabbit/aggbug/406007.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.qpkxbc.shop/rabbit/" target="_blank">Rabbit</a> 2013-11-05 14:31 <a href="http://www.qpkxbc.shop/rabbit/archive/2013/11/05/406007.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用 EclEmma q行覆盖试http://www.qpkxbc.shop/rabbit/archive/2013/11/01/405872.htmlRabbitRabbitFri, 01 Nov 2013 01:43:00 GMThttp://www.qpkxbc.shop/rabbit/archive/2013/11/01/405872.htmlhttp://www.qpkxbc.shop/rabbit/comments/405872.htmlhttp://www.qpkxbc.shop/rabbit/archive/2013/11/01/405872.html#Feedback0http://www.qpkxbc.shop/rabbit/comments/commentRss/405872.htmlhttp://www.qpkxbc.shop/rabbit/services/trackbacks/405872.html覆盖试是衡量测试质量的一个重要指标。在对一个Y件品进行了单元试、组装测试、集成测试以及接受测试等J多的测试之后,我们能不能就此对软g的质量生一定的信心呢?q就需要我们对试的质量进行考察。如果测试仅覆盖了代码的一部分,那么不管我们写了多少试用例Q我们也不能怿软g质量是有保证的。相反,如果试覆盖C软g的绝大部分代码,我们p对Y件的质量有一个合理的信心。本文将介绍一个优U的开源Y件测试工?EclEmmaQ它能够对由 Java 语言~写的程序进行覆盖测试,从而对E序q行的结果生成详的覆盖试报告?/p>

介绍

现在 IT 开发h员比以往M时候都更加x试的重要性,没有l过良好试的代码更Ҏ出问题。在极限~程中,试驱动开发已l被证明是一U有效提高Y件质量的Ҏ。在试驱动的开发方式中QY件工E师在编写功能代码之前首先编写测试代码,q样能从最开始保证程序代码的正确性,q且能够在程序的每次演进时进行自动的回归试。测试对于Y件品的成|L臛_重要的作用,在极限编E领域,甚至有h提议M未经试的代码都应该自动从发布的产品中删除。作者ƈ不确信这个观Ҏ正确的,但是试本n的质量确实是一个需要高度关注的问题。测试的覆盖率是试质量的一个重要指标,我们需要工h帮助我们q行对Y件测试覆盖的考察?/p>

EclEmma 是q样一个能帮助开发h员考察试覆盖率的优秀?Eclipse 开源插件。EclEmma 在覆盖测试领域是如此的优UQ以致于它在q去不久?2006 q成Z Eclipse Community Awards Winners 册选手。虽然最?Eclipse Checkstyle Plugin 取得?Best Open Source Eclipse-based Developer tool 的称P但我们也可以由此看到 EclEmma 对开发h员的帮助是巨大的QEclipse Community Award 的具体信息可以参?参考资?/a>Q?/p>

提到 EclEmma 首先p说到著名?Java 覆盖试工具 Emma。Emma 是一个在 SourceForge 上进行的开源项目(参阅 参考资?/a>Q。从某种E度上说QEclEmma 可以看作?Emma 的一个图形界面。在本文?a href="http://www.ibm.com/developerworks/cn/java/j-lo-eclemma/#resources">参考文?/a>中,可以看到专门讲述使用 Emma 的技术文章?/p>

Emma 的作者开?Emma 之初Q程序员已经有了各种各样优秀的开?Java 开发工兗D例来_我们有优U的集成开发环?EclipseQ有开源的 JDKQ有单元试工具 JUnitQ有 Ant q样的项目管理工P我们q可以用 CVS ?SubVersion 来进行源代码版本的维护。当时看来,也许唯一~少的就是一个开源的覆盖试工具了。Emma 是Z填补q项I白而生的。现在的情况已经?Emma 诞生的时候不一L。时至今日,我们已经有了不少的覆盖测试工兗例?Coverlipse 是一个基?Eclipse 的覆盖测试插件。其他还?CoberturaQQuilt ?JCoverage {。但?Emma h一些非怼U的特性得它更适合被广泛的使用。和 Coverlipse {工hhQEmma 是开源的Q同时它对应用程序执行速度的媄响非常小?/p>

EclEmma 的出现I补了 Emma 用户一个大的遗?---- ~Z囑Ş界面以及寚w成开发环境的支持。将 Eclipse ?Emma q两个在各自领域最ZU的工L合v来,q就?EclEmma 为我们提供的。接下来Q我们就要在后箋章节中和读者朋友一L?EclEmma 为开发h员提供了什么?/p>

安装 EclEmma 插g

安装 EclEmma 插g的过E和大部?Eclipse 插g相同Q我们既可以通过 Eclipse 标准?Update 机制来远E安?EclEmma 插gQ?a href="http://www.ibm.com/developerworks/cn/java/j-lo-eclemma/#fig001">?1Q,也可以从站点Q参?参考资?/a>Q下?zip 文gq解压到 eclipse 所在的目录中?/p>

?1 d EclEmma 更新站点
?1 d EclEmma 更新站点

不管采用何种方式来安?EclEmmaQ安装完成ƈ重新启动 Eclipse 之后Q工h上应该出C个新的按钮:

?2 新增的覆盖测试按?/h5>?2 新增的覆盖测试按? src=

使用 EclEmma 试 Java E序

Z实验 EclEmma 的特性,我们首先?Eclipse ?Workspace 中徏立一个名UCؓ test.emma 的新 Java 目。接下来Q我们在其中建立一?HelloWorld c,其代码如下所C:

清单 1 用于试 EclEmma 的代?/h5>
package test.emma;

public class HelloWorld {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int rand = (int) (Math.random()*100);
		if(rand%2==0){
			System.out.println( "Hello, world! 0");
		}
		else
			System.out.println("Hello, world! 1");
		
		int result = rand%2==0? rand+rand:rand*rand; 
		System.out.println(result);
	}
}

接下来,我们通过 EclEmma q行 HelloWorld.main() 函数?/p>

?3 ?Java 应用E序q行覆盖试
?3 ?Java 应用E序q行覆盖试

执行完毕之后Q我们正在编?HelloWorld.java 的窗口将会变成如下所C:

?4 q行覆盖试的结?/h5>?4 q行覆盖试的结? src=

?Java ~辑器中QEclEmma 用不同的色彩标示了源代码的测试情c其中,l色的行表示该行代码被完整的执行Q红色部分表C行代码根本没有被执行Q而黄色的行表明该行代码部分被执行。黄色的行通常出现在单行代码包含分支的情况Q例??4 中的 16 行就昄为黄艌Ӏ由于程序中有一个随机确定的分支Q因此读者的H口可能与这里稍有不同(11 行或?14 行中有且只有一个红色的行)?/p>

除了在源代码~辑H口直接q行着色之外,EclEmma q提供了一个单独的视图来统计程序的覆盖试率?/p>

?5 察看E序的覆盖测试率
?5 察看E序的覆盖测试率

EclEmma 提供?Coverage 视图能够分层的显CZ码的覆盖试率,?5 中的信息表明我们?HelloWorld 的一ơ运行覆盖了大约 68.6% 的代码?/p>

惛_一ơ运行中覆盖所有的代码通常比较困难Q如果能把多ơ测试的覆盖数据l合hq行察看Q那么我们就能更方便的掌握多ơ测试的试效果。EclEmma 提供了这L功能。现在,让我们重复数ơ对 HelloWorld 的覆盖测试。我们注意到 Coverage 视图L昄最新完成的一ơ覆盖测试。事实上QEclEmma 为我们保存了所有的试l果。接下来Q我们将通过 Coverage 视图的工h钮来l合多次覆盖试的结果?/p>

?6 用于l合多次覆盖试l果的工h按钮
?6 用于l合多次覆盖试l果的工h按钮

当我们多ơ运?Coverage 之后Q我们可以单??6 所C工h按钮。之后,一个对话框被弹出以供用户选择需要合q的覆盖试?/p>

?7 选择需要合q的覆盖试l果
?7 选择需要合q的覆盖试l果

在合q完成之后,我们可以观察?Java ~辑器和 Coverage 视图中都昄了合q之后的l果Q?/p>

?8 察看合ƈ后的覆盖试l果
?8 察看合ƈ后的覆盖试l果

?8 中,我们可以看到Q通过多次q行覆盖试Q最l我们的代码辑ֈ?91.4% 的测试覆盖率。有的是,图中W三行代码被标记为红Ԍ而此行代码实际上是不可执行的。奥妙在于,我们没有生成M HelloWorld cȝ实例Q因此缺省构造函数没有被调用Q?EclEmma 这个特D代码的覆盖状态标记在cd明的W一行?/p>


EclEmma 的高U特?/h2>

如果 EclEmma 只能试 Java Application 的测试覆盖率Q那么它相对命o行版本的 Emma 来说Q提供的增强׃多了。相反,EclEmma 提供了很多与 Eclipse 紧密l合的功能。它不仅能测?Java ApplicationQ还能计?JUnit 单元试Q对 Eclipse 插g试的覆盖率。从 ?9 中我们可以看?EclEmma 目前支持四种cd的程序?/p>

?9 EclEmma 的配|页?/h5>?9 EclEmma 的配|页? src=

Z了解 EclEmma 是如何获得覆盖测试数据的Q我们需要先?Emma 有初步的了解。通常代码覆盖试工具都需要对被执行的代码q行修改。?Emma 提供了两U方式来完成qg事?/p>

  1. 预插入模式:对程序进行测量之前,需要采?Emma 提供的工具对 class 文g或?jar 文gq行修改。修改完成之后的代码可以立刻被执行。覆盖测试的l果会被存攑ֈ指定的文件中?/li>
  2. x插入模式Q?/strong>x插入模式不需要事先对代码q行修改。相反,对代码的修改是通过一?Emma 定制?Class loaderQ类载入器)q行的。这U方式的优点很明显,我们不需要对 class 或?jar 文gq行M修改。缺Ҏ我们Z获得试的结果,需要用 Emma 提供的命?emmarun 来执?Java 应用E序?/li>

使用x插入模式的优点很明显Qclass 文g?jar 文g不会被修攏V而预插入模式的应用范围更为广泛,对于某些需要嵌入到框架中运行的代码来说Q例?EJBQ,我们只能使用预插入模式。EclEmma 仅仅使用?Emma 的预插入模式来工作,不过 EclEmma ~省会在临时目录中创?class 文g?jar 文g的副本来q行修改Q因此在 workspace ?class ?jar 文g仍然保持原样。虽然听上去很好Q但是由于需要修?classpath 来用修改过?class ?jar 文gQ对于不能修?classpath 的应用(例如 Eclipse RCP ?JUnit Plugin TestQ来_我们q是只能选择修改 workspace 中的 class 文g?jar 文g。对?Java Application ?JUnit cd的覆盖测试,我们可以在配|对话框中选中“In-place instrumentation”Ҏ指定直接修改 Workspace 中的 .class 文g?.jar 文g?/p>



Rabbit 2013-11-01 09:43 发表评论
]]>
ZXfire SOAP Header的WebService安全验证教程 .http://www.qpkxbc.shop/rabbit/archive/2013/10/24/405610.htmlRabbitRabbitThu, 24 Oct 2013 08:28:00 GMThttp://www.qpkxbc.shop/rabbit/archive/2013/10/24/405610.htmlhttp://www.qpkxbc.shop/rabbit/comments/405610.htmlhttp://www.qpkxbc.shop/rabbit/archive/2013/10/24/405610.html#Feedback1http://www.qpkxbc.shop/rabbit/comments/commentRss/405610.htmlhttp://www.qpkxbc.shop/rabbit/services/trackbacks/405610.htmlWebSerice是一U开攄web服务QQ何h都可以访问,但我们有时候需要考虑只有付费用户才能使用WS,所以,我们需要对WS加入安全验证机制Q当Ӟ可以利用防火墙的IPqoQweb应用的配|从最外层去隔非法用P但在内层Q我们也可以使用SOAP Header的方式,由客L发送验证数据,服务端验通过后基WS讉K权限

首先Ҏ我的q篇Blog

http://blog.csdn.net/daryl715/archive/2007/07/25/1707161.aspx

配置WS Server和WS ClientQ?font color="#ff0000">其中Client端的试代码cd由Client改ؓClientTest,因ؓ我们要用到Xfire的一个名为Client的类 

 

首先我们~写服务端验证类l承AbstractHandler

 

package test;

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.handler.AbstractHandler;
import org.jdom.Element;

public class AuthenticationHandler extends AbstractHandler {

    
public void invoke(MessageContext cfx) throws Exception {
           
if(cfx.getInMessage().getHeader() == null)
           
{
               
throw new org.codehaus.xfire.fault.XFireFault("h必须包含验证信息",org.codehaus.xfire.fault.XFireFault.SENDER);
           }

           Element token
=cfx.getInMessage().getHeader().getChild("AuthenticationToken");
           
if (token == null
           

            
throw new org.codehaus.xfire.fault.XFireFault("h必须包含w䆾验证信息", org.codehaus.xfire.fault.XFireFault.SENDER); 
           }
 

              String username 
= token.getChild("Username").getValue(); 
              String password 
= token.getChild("Password").getValue(); 
              
try 
              

                  
//q行w䆾验证 Q只有abcd@1234的用户ؓ授权用户
                 if(username.equals("abcd"&& password.equals("1234"))
                  
//q语句不昄
                  System.out.println("w䆾验证通过");
                 
else throw new Exception();
              }
 
              
catch (Exception e) 
              

                  
throw new   org.codehaus.xfire.fault.XFireFault("非法的用户名和密?/span>",   org.codehaus.xfire.fault.XFireFault.SENDER); 
              }
 

          }
 



}

 

下面是Client发送授权信?/p>

 

package test;

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.handler.AbstractHandler;
import org.jdom.Element;

public class ClientAuthenticationHandler extends AbstractHandler {

     
private String username = null

     
private String password = null

     
public ClientAuthenticationHandler() 

     }
 

     
public ClientAuthenticationHandler(String username,String password) 

         
this.username = username; 

         
this.password = password; 
     }
 

     
public void setUsername(String username) 

         
this.username = username; 

     }
 

     
public void setPassword(String password) 

         
this.password = password; 

     }
 

     
public void invoke(MessageContext context) throws Exception 

         
//为SOAP Header构造验证信?/span>
         Element el = new Element("header"); 
         context.getOutMessage().setHeader(el); 
         Element auth 
= new Element("AuthenticationToken"); 
         Element username_el 
= new Element("Username"); 
         username_el.addContent(username); 
         Element password_el 
= new Element("Password"); 
         password_el.addContent(password); 
         auth.addContent(username_el); 
         auth.addContent(password_el); 
         el.addContent(auth); 
     }
 



}

为ClientTest.java加入以下代码

 XFireProxy proxy = (XFireProxy)Proxy.getInvocationHandler(service);
Client client = proxy.getClient();
client.addOutHandler(new ClientAuthenticationHandler("abcd1","1234"));

{等Q还没有完,修改Services.xm为WSl定Handler

  

<?xml version="1.0" encoding="UTF-8"?>


<beans>
<service xmlns="http://xfire.codehaus.org/config/1.0">
<name>HelloService</name>
<namespace>http://test/HelloService</namespace>
<serviceClass>test.IHelloService</serviceClass>
<implementationClass>test.HelloServiceImpl</implementationClass>
 
<inHandlers> 
 
<handler  handlerClass ="test.AuthenticationHandler" ></handler > 
 
</inHandlers>
</service>
</beans>


q样我们完成了~码Q下面启动tomcatQ运行客L代码Q本文ؓabcd@1234位授权用P使用abcd@1234,可以正常讉KWS,如果用错误帐P则会有以下异?/font>

 

Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: 非法的用户名和密?br />org.codehaus.xfire.fault.XFireFault: 非法的用户名和密?br />    at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
    at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
    at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
    at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
    at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
    at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
    at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
    at org.codehaus.xfire.client.Client.invoke(Client.java:336)
    at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
    at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
    at $Proxy0.getUser(Unknown Source)
    at test.ClientTest.main(ClientTest.java:39)

 

如果不在CientTest加以下增加Heade则会有以下异?/p>

 XFireProxy proxy = (XFireProxy)Proxy.getInvocationHandler(service);
Client client = proxy.getClient();
 client.addOutHandler(new ClientAuthenticationHandler("abcd1","1234"));

Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: h必须包含验证信息
org.codehaus.xfire.fault.XFireFault: h必须包含验证信息
    at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
    at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
    at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
    at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
    at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
    at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
    at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
    at org.codehaus.xfire.client.Client.invoke(Client.java:336)
    at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
    at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
    at $Proxy0.getUser(Unknown Source)
    at test.ClientTest.main(ClientTest.java:35)


Rabbit 2013-10-24 16:28 发表评论
]]>java实现单的单点d(转蝲)http://www.qpkxbc.shop/rabbit/archive/2013/10/18/405392.htmlRabbitRabbitFri, 18 Oct 2013 01:44:00 GMThttp://www.qpkxbc.shop/rabbit/archive/2013/10/18/405392.htmlhttp://www.qpkxbc.shop/rabbit/comments/405392.htmlhttp://www.qpkxbc.shop/rabbit/archive/2013/10/18/405392.html#Feedback0http://www.qpkxbc.shop/rabbit/comments/commentRss/405392.htmlhttp://www.qpkxbc.shop/rabbit/services/trackbacks/405392.html阅读全文

Rabbit 2013-10-18 09:44 发表评论
]]>
解决IE下Iframe的Session丢失http://www.qpkxbc.shop/rabbit/archive/2013/06/09/400441.htmlRabbitRabbitSun, 09 Jun 2013 07:57:00 GMThttp://www.qpkxbc.shop/rabbit/archive/2013/06/09/400441.htmlhttp://www.qpkxbc.shop/rabbit/comments/400441.htmlhttp://www.qpkxbc.shop/rabbit/archive/2013/06/09/400441.html#Feedback1http://www.qpkxbc.shop/rabbit/comments/commentRss/400441.htmlhttp://www.qpkxbc.shop/rabbit/services/trackbacks/400441.htmlȝ面用的是Iframe做的 动态内容嵌?需要登?但是每次h session 都失?...

整个应用在FF下是正常的,但是在IE下每ơ点M一늚时候都要重新登录。经q调试发现刷新后h采用了新?sessionIdQ于是怀疑到了是Iframe的问题。在|上搜了一下,果真是IE的Iframe问题。IE6/IE7支持的P3P(Platform for Privacy Preferences Project (P3P) specification)协议默认LW三Ҏ隐私安全声明的cookieQFirefox目前q不支持P3P安全?性,firefox中不存在此问题?br />具体的解x式是在登录的Action处理Ҏ?/span>加上 
response.setHeader("P3P","CP=CAO PSA OUR IDC DSP COR ADM DEVi TAIi PSD IVAi IVDi CONi HIS IND CNT"); 
问题搞定Q?/p>

Rabbit 2013-06-09 15:57 发表评论
]]>
struts 2标签 <s:textfield> 样式问题http://www.qpkxbc.shop/rabbit/archive/2013/06/05/400213.htmlRabbitRabbitWed, 05 Jun 2013 02:29:00 GMThttp://www.qpkxbc.shop/rabbit/archive/2013/06/05/400213.htmlhttp://www.qpkxbc.shop/rabbit/comments/400213.htmlhttp://www.qpkxbc.shop/rabbit/archive/2013/06/05/400213.html#Feedback0http://www.qpkxbc.shop/rabbit/comments/commentRss/400213.htmlhttp://www.qpkxbc.shop/rabbit/services/trackbacks/400213.html初学struts2Q在头脑中一直在想一个问题,是对于struts2 Q当应用其自w的标签Ӟ例如Q?/p>

<s:form>

   <s:textfield name="a"></s:textfield>

</s:form>

当查看源代码时ؓQ?/p>

<form>

<table>

    <tr><td><input type="text" name=a/></td></tr>

</table>

</form>

自动d的table tr td 标签Q但如果?一行显C多列怎么办?

|上查了查,有好多奇怪的解决办法Q比如说通过在页面上判断Q看什么时候输?lt;tr> 标签Q但我认为,struts2q样做,那也太不人道了,后终于查到原因,现ȝ如下Q?/p>

原理Q在struts2中加入了theme(主题Q的概念Q通过讄不同的主题,可以让struts的代码输Z同的html代码Q你也就相应得到不同的布局效果?/p>

问题一QStruts2有哪些主题?

Struts2提供了三U主题,ajax, simple, xhtmlQ它默认的是xhtml主题Q当然你可以写Q意个你自q主题,我们UC定义主题

问题二:Struts2怎么改?

有两U方法可以解?

1.单的ҎQ也很实用)

在Struts.xml中,加上下一行代码就可以?/p>

<constant name="struts.ui.theme" value="simple" />

代表所有的面采用的都?simple主题了,q时它输出的面Q不回添加Q何多余的代码Q比?table tr td {,我们可以像其他~辑面的方式编辑页面的风格?/p>

或??<s:form 中添?theme

<s:form theme="simple"></s:form>

struts2每个标签都有theme属?/p>

2.在Struts.properties里改Q?/p>

#讄主题
struts.ui.theme=simple

可见另一:struts.properties



Rabbit 2013-06-05 10:29 发表评论
]]>
ORACLE中Like与Instr模糊查询性能大比?/title><link>http://www.qpkxbc.shop/rabbit/archive/2013/01/21/394510.html</link><dc:creator>Rabbit</dc:creator><author>Rabbit</author><pubDate>Mon, 21 Jan 2013 07:51:00 GMT</pubDate><guid>http://www.qpkxbc.shop/rabbit/archive/2013/01/21/394510.html</guid><wfw:comment>http://www.qpkxbc.shop/rabbit/comments/394510.html</wfw:comment><comments>http://www.qpkxbc.shop/rabbit/archive/2013/01/21/394510.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.qpkxbc.shop/rabbit/comments/commentRss/394510.html</wfw:commentRss><trackback:ping>http://www.qpkxbc.shop/rabbit/services/trackbacks/394510.html</trackback:ping><description><![CDATA[<p align="left" style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><strong><span verdana","sans-serif";""="" 宋体;color:black;"="">ORACLE</span></strong><strong><span style="font-family: 宋体; color: black;">?/span></strong><strong><span verdana","sans-serif";""="" 宋体;color:black;"="">Like</span></strong><strong><span style="font-family: 宋体; color: black;">?/span></strong><strong><span verdana","sans-serif";="" color:black;""="" 0pt;"="">Instr</span></strong><strong><span style="font-family: 宋体; color: black;">模糊查询性能大比?/span></strong><strong></strong></p><p align="left" style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p align="left" style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">instr(title,'</span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">手册</span><span verdana","sans-serif";="" color:red;"="" style="line-height: 28px; font-size: 12pt;">')>0  </span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">相当?/span><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">  title like '%</span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">手册</span><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">%'</span></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">instr(title,'</span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">手册</span><span verdana","sans-serif";="" color:red;"="" style="line-height: 28px; font-size: 12pt;">')=1  </span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">相当?/span><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">  title like '</span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">手册</span><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">%'</span></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">instr(title,'</span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">手册</span><span verdana","sans-serif";="" color:red;"="" style="line-height: 28px; font-size: 12pt;">')=0  </span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">相当?/span><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">  title not like '%</span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">手册</span><span verdana","sans-serif";="" color:red;""="" 0pt;"="" style="line-height: 28px; font-size: 12pt;">%'</span></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">t</span><span style="font-family: 宋体; color: black;">表中近?/span><span verdana","sans-serif";="" color:black;"="">1100</span><span style="font-family: 宋体; color: black;">万数据,很多时候,我们要进行字W串匚wQ在</span><span verdana","sans-serif";="" color:black;"="">SQL</span><span style="font-family: 宋体; color: black;">语句中,我们通常使用</span><span verdana","sans-serif";""="" 宋体;color:black;"="">like</span><span style="font-family: 宋体; color: black;">来达到我们搜索的目标。但l过实际试发现Q?/span><span verdana","sans-serif";="" color:black;""="" 0pt;"="">like</span><span style="font-family: 宋体; color: black;">的效率与</span><span verdana","sans-serif";""="" 宋体;color:black;"="">instr</span><span style="font-family: 宋体; color: black;">函数差别相当大。下面是一些测试结果:</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">SQL> set timing on<br />SQL> select count(*) from t where instr(title,'</span><span style="font-family: 宋体; color: black;">手册</span><span verdana","sans-serif";="" color:black;"="">')>0;</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">  COUNT(*)<br />----------<br />     65881</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">Elapsed: 00:00:11.04<br />SQL> select count(*) from t where title like '%</span><span style="font-family: 宋体; color: black;">手册</span><span verdana","sans-serif";="" color:black;"="">%';</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">  COUNT(*)<br />----------<br />     65881</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">Elapsed: 00:00:31.47<br />SQL> select count(*) from t where instr(title,'</span><span style="font-family: 宋体; color: black;">手册</span><span verdana","sans-serif";="" color:black;"="">')=0;</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">  COUNT(*)<br />----------<br />  11554580</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">Elapsed: 00:00:11.31<br />SQL> select count(*) from t where title not like '%</span><span style="font-family: 宋体; color: black;">手册</span><span verdana","sans-serif";="" color:black;"="">%';</span></p><p align="left" style="line-height: 25px; margin: 7.5pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span verdana","sans-serif";="" color:black;""="" 0pt;"="">  COUNT(*)<br />----------<br />  11554580</span></p><p align="left" style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span style="font-family: 宋体; color: black;">另外Q我在结另外一?/span><span verdana","sans-serif";""="" 宋体;color:black;"="">2</span><span style="font-family: 宋体; color: black;">亿多的表Q?/span><span verdana","sans-serif";="" color:black;""="" 0pt;"="">8</span><span style="font-family: 宋体; color: black;">个ƈ行,使用</span><span verdana","sans-serif";="" color:black;"="">like</span><span style="font-family: 宋体; color: black;">查询很久都不出来l果Q但使用</span><span verdana","sans-serif";""="" 宋体;color:black;"="">instr,4</span><span style="font-family: 宋体; color: black;">分钟卛_成查找,性能是相当的好。这些小技巧用好,工作效率提高不少。通过上面的测试说明,</span><span verdana","sans-serif";="" color:black;""="" 0pt;"="">ORACLE</span><span style="font-family: 宋体; color: black;">内徏的一些函敎ͼ是经q相当程度的优化的?/span></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span style="color: red;">instr(title,’aaa’)>0 </span><span style="color: red;">相当于like</span></p><p style="line-height: 25px; margin: 11.25pt 0cm; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span style="font-size: 10.5pt; color: red;">instr(title,’aaa’)=0 </span><span style="font-size: 10.5pt; color: red;">相当于not like</span></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><strong><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">Ҏ用法Q?/span></strong><strong></strong></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span style="line-height: 28px; font-size: 12pt; color: red;">select   id, name from users where instr('101914, 104703', id) > 0; <br />  </span><span style="line-height: 28px; font-size: 12pt; font-family: 宋体; color: red;">它等价于</span><span style="line-height: 28px; font-size: 12pt; color: red;"> <br />select   id, name from users where id = 101914 or id = 104703;</span></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"> </p><p align="left" style="line-height: 22px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: white; word-break: break-all;"><span style="line-height: 25px;"><a rel="nofollow" href="http://www.qpkxbc.shop/heyang/archive/2011/07/17/354478.html" style="color: #863417; text-decoration: initial;"><strong><span style="line-height: 24px; font-size: 11pt; font-family: 宋体; color: #646464;"><span style="line-height: 27px;">使用</span></span></strong><strong><span verdana","sans-serif";="" color:#646464;"="" style="line-height: 24px; font-size: 11pt;">Oracle</span></strong><strong><span style="line-height: 24px; font-size: 11pt; font-family: 宋体; color: #646464;"><span style="line-height: 27px;">?/span></span></strong><strong><span verdana","sans-serif";="" color:#646464;"="" style="line-height: 24px; font-size: 11pt;">instr</span></strong><strong><span style="line-height: 24px; font-size: 11pt; font-family: 宋体; color: #646464;"><span style="line-height: 27px;">函数与烦引配合提高模p查询的效率</span></span></strong></a></span><strong style="line-height: 25px;"></strong></p><p align="left" style="line-height: 22px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: white; word-break: break-all;"><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">一般来_?/span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 19px; font-size: 9pt;">Oracle</span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">数据库中Q我们对</span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 19px; font-size: 9pt;">tb</span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">表的</span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 19px; font-size: 9pt;">name</span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">字段q行模糊查询会采用下面两U方式:</span><span verdana","sans-serif";="" color:#4b4b4b;""="" 0pt;"="" style="line-height: 19px; font-size: 9pt;"><br style="line-height: 21px;" />1.select * from tb where name like '%XX%';<br style="line-height: 21px;" />2.select * from tb where instr(name,'XX')>0;<br style="line-height: 21px;" /><br style="line-height: 21px;" /></span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">若是?/span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 19px; font-size: 9pt;">name</span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">字段上没有加索引Q两者效率差不多Q基本没有区别?/span><span verdana","sans-serif";="" color:#4b4b4b;""="" 0pt;"="" style="line-height: 19px; font-size: 9pt;"><br style="line-height: 21px;" /><br style="line-height: 21px;" /></span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">为提高效率,我们?/span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 19px; font-size: 9pt;">name</span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">字段上可以加上非唯一性烦引:</span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 19px; font-size: 9pt;"><br style="line-height: 21px;" />create index idx_tb_name on tb(name);<br style="line-height: 21px;" /><br style="line-height: 21px;" /></span><span style="line-height: 19px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">q样Q再使用</span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 19px; font-size: 9pt;"></span></p><p align="left" style="line-height: 22px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: white; word-break: break-all;"><span verdana","sans-serif";="" color:#4b4b4b;""="" 0pt;"="" style="line-height: 19px; font-size: 9pt;">select * from tb where instr(name,'XX')>0;</span></p><p style="line-height: 25px; margin: 0px 0px 10px; padding: 0px; color: #4c402b; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #fbf8f4;"><span style="line-height: 21px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">q样的语句查询,效率可以提高不少Q表数据量越大时两者差别越大。但也要֏?/span><span verdana","sans-serif";="" color:#4b4b4b;""="" 0pt;"="" style="line-height: 21px; font-size: 9pt;">name</span><span style="line-height: 21px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">字段加上索引?/span><span verdana","sans-serif";""="" 宋体;color:#4b4b4b;"="" style="line-height: 21px; font-size: 9pt;">DML</span><span style="line-height: 21px; font-size: 9pt; font-family: 宋体; color: #4b4b4b;">语句会索引数据重新排序的媄响?/span></p><img src ="http://www.qpkxbc.shop/rabbit/aggbug/394510.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.qpkxbc.shop/rabbit/" target="_blank">Rabbit</a> 2013-01-21 15:51 <a href="http://www.qpkxbc.shop/rabbit/archive/2013/01/21/394510.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <a href="http://www.qpkxbc.shop/"><span class="STYLE1">1һ152ͼ</span></a> <script>(function(){ var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?9ed1f3a8f9c3ff069b7b95c01474c743":"https://jspassport.ssl.qhimg.com/11.0.1.js?9ed1f3a8f9c3ff069b7b95c01474c743"; document.write('<script src="' + src + '" id="sozz"><\/script>'); })(); </script> <a href="http://www.313084.live">456ư׿</a> <a href="http://www.9917956.live">ʮһѡ忪</a> <a href="http://www.783745.live">ʲô׬Ǯ</a> <a href="http://www.8306023.live">11ѡ5Ʊͼ</a> <a href="http://www.751806.live">dnfװˢʲôͼ׬Ǯ</a> <a href="http://067610.live">ʹƱʹ˾</a> <a href="http://www.4092092.live">˿רҵ</a> <a href="http://www.479351.live">Ф</a> <a href="http://www.3684540.live">11ѡ5һţ</a> <a href="http://www.3498390.live">ְʤֲʲô˼</a> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>