??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲春色在线视频,亚洲丰满熟女一区二区哦,亚洲欧美自偷自拍另类视http://www.tkk7.com/absolutedo/宝剑锋从砺?梅花香自苦寒来?/description>zh-cnSat, 10 May 2025 10:48:08 GMTSat, 10 May 2025 10:48:08 GMT60ORA-00054:resource busy and acquire with nowait specified(资源正忙Q需指定nowait)解决Ҏhttp://www.tkk7.com/absolutedo/archive/2010/11/27/339196.htmlabsoluteabsoluteSat, 27 Nov 2010 06:55:00 GMThttp://www.tkk7.com/absolutedo/archive/2010/11/27/339196.htmlhttp://www.tkk7.com/absolutedo/comments/339196.htmlhttp://www.tkk7.com/absolutedo/archive/2010/11/27/339196.html#Feedback0http://www.tkk7.com/absolutedo/comments/commentRss/339196.htmlhttp://www.tkk7.com/absolutedo/services/trackbacks/339196.html

1> 通过此语句查询正在锁定的SESSION_ID:

1SELECT  SESSION_ID   FROM   V$LOCKED_OBJECT,USER_OBJECTS  WHERE   V$LOCKED_OBJECT.OBJECT_ID   =   USER_OBJECTS.OBJECT_ID


2> 通过W一步查询到的SESSION_ID查询SERIAL#

1SELECT SERIAL# FROM V$SESSION  WHERE SID='12'(此处'12'Z面查询到?/span>'SESSION_ID')


 3> Ҏ1,2步查询到的SESSION_ID和SERIAL#执行

1ALTER   SYSTEM   KILL   SESSION  '12,154'(12为SESSION_ID的? 154为SERIAL#的?

4> 如果利用上面的命令杀M个进E后Q进E状态被|ؓ"killed"Q但是锁定的资源很长旉没有被释放,那么q可以在os一U再杀ȝ应的q程(U程)Q首先执行下面的语句获得当前q程(U程)的标CPIDQ?br />
1select spid, osuser, s.program 
2from v$session s,v$process p
3where s.paddr=p.addr and s.sid=12 (12是上面的SESSION_ID)

然后在OS通过d理器找到对应的q程Q在杀死这个进E?U程)



absolute 2010-11-27 14:55 发表评论
]]>
存储q程学习-扚w插入10000条数据进数据?/title><link>http://www.tkk7.com/absolutedo/archive/2010/11/27/339194.html</link><dc:creator>absolute</dc:creator><author>absolute</author><pubDate>Sat, 27 Nov 2010 06:41:00 GMT</pubDate><guid>http://www.tkk7.com/absolutedo/archive/2010/11/27/339194.html</guid><wfw:comment>http://www.tkk7.com/absolutedo/comments/339194.html</wfw:comment><comments>http://www.tkk7.com/absolutedo/archive/2010/11/27/339194.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/absolutedo/comments/commentRss/339194.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/absolutedo/services/trackbacks/339194.html</trackback:ping><description><![CDATA[最q在学习存储q程Q以前在目中没有怎么接触q!<br /> <br /> 我通过存储q程像数据库中批量添加一千万(100000000)条记?l果PL/SQL很长旉没有反映Q结果不得已通过脚本杀掉当前进E,我重新通过存储q程插入10000条数据?br /> <br /> 脚本Q?br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><span style="color: #008080"> 1</span><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /><span style="color: #008080">--</span><span style="color: #008080">删除用户?/span><span style="color: #008080"><br /> </span><span style="color: #008080"> 2</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">DROP</span><span style="color: #000000"> </span><span style="color: #0000ff">TABLE</span><span style="color: #000000"> T_PORTAL_USER;<br /> </span><span style="color: #008080"> 3</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /><br /> </span><span style="color: #008080"> 4</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">创徏用户?/span><span style="color: #008080"><br /> </span><span style="color: #008080"> 5</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">CREATE</span><span style="color: #000000"> </span><span style="color: #0000ff">TABLE</span><span style="color: #000000"> T_PORTAL_USER<br /> </span><span style="color: #008080"> 6</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />(<br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />    id </span><span style="color: #000000; font-weight: bold">NUMBER</span><span style="color: #000000"> </span><span style="color: #0000ff">PRIMARY</span><span style="color: #000000"> </span><span style="color: #0000ff">KEY</span><span style="color: #000000">, </span><span style="color: #008080">--</span><span style="color: #008080"> 用户表示</span><span style="color: #008080"><br /> </span><span style="color: #008080"> 8</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">    username </span><span style="color: #000000; font-weight: bold">VARCHAR2</span><span style="color: #000000">(</span><span style="color: #800000; font-weight: bold">24</span><span style="color: #000000">) </span><span style="color: #808080">NOT</span><span style="color: #000000"> </span><span style="color: #0000ff">NULL</span><span style="color: #000000">,</span><span style="color: #008080">--</span><span style="color: #008080"> 用户?/span><span style="color: #008080"><br /> </span><span style="color: #008080"> 9</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">    password </span><span style="color: #000000; font-weight: bold">VARCHAR2</span><span style="color: #000000">(</span><span style="color: #800000; font-weight: bold">24</span><span style="color: #000000">) </span><span style="color: #808080">NOT</span><span style="color: #000000"> </span><span style="color: #0000ff">NULL</span><span style="color: #000000">,</span><span style="color: #008080">--</span><span style="color: #008080"> 密码</span><span style="color: #008080"><br /> </span><span style="color: #008080">10</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">    realname </span><span style="color: #000000; font-weight: bold">VARCHAR2</span><span style="color: #000000">(</span><span style="color: #800000; font-weight: bold">24</span><span style="color: #000000">) </span><span style="color: #808080">NOT</span><span style="color: #000000"> </span><span style="color: #0000ff">NULL</span><span style="color: #000000">,</span><span style="color: #008080">--</span><span style="color: #008080"> 真实姓名</span><span style="color: #008080"><br /> </span><span style="color: #008080">11</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">    sex </span><span style="color: #000000; font-weight: bold">VARCHAR2</span><span style="color: #000000">(</span><span style="color: #800000; font-weight: bold">2</span><span style="color: #000000">) </span><span style="color: #0000ff">DEFAULT</span><span style="color: #000000"> </span><span style="color: #ff0000">'</span><span style="color: #ff0000">0</span><span style="color: #ff0000">'</span><span style="color: #000000">,</span><span style="color: #008080">--</span><span style="color: #008080"> 性别 "0":Male "1":Female</span><span style="color: #008080"><br /> </span><span style="color: #008080">12</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">    registerDate </span><span style="color: #000000; font-weight: bold">TIMESTAMP</span><span style="color: #000000"> </span><span style="color: #808080">NOT</span><span style="color: #000000"> </span><span style="color: #0000ff">NULL</span><span style="color: #000000">,</span><span style="color: #008080">--</span><span style="color: #008080"> 注册日期</span><span style="color: #008080"><br /> </span><span style="color: #008080">13</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">    state </span><span style="color: #000000; font-weight: bold">VARCHAR2</span><span style="color: #000000">(</span><span style="color: #800000; font-weight: bold">2</span><span style="color: #000000">) </span><span style="color: #808080">NOT</span><span style="color: #000000"> </span><span style="color: #0000ff">NULL</span><span style="color: #000000"> </span><span style="color: #008080">--</span><span style="color: #008080"> 账号状?nbsp;"0":启用  "1":注销</span><span style="color: #008080"><br /> </span><span style="color: #008080">14</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">)<br /> </span><span style="color: #008080">15</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /><br /> </span><span style="color: #008080">16</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">删除用户表序?/span><span style="color: #008080"><br /> </span><span style="color: #008080">17</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">DROP</span><span style="color: #000000"> SEQUENCE SEQ_T_PORTAL_USER;<br /> </span><span style="color: #008080">18</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /><br /> </span><span style="color: #008080">19</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">创徏用户表序?/span><span style="color: #008080"><br /> </span><span style="color: #008080">20</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">CREATE</span><span style="color: #000000"> SEQUENCE SEQ_T_PORTAL_USER<br /> </span><span style="color: #008080">21</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />START </span><span style="color: #0000ff">WITH</span><span style="color: #000000"> </span><span style="color: #800000; font-weight: bold">1</span><span style="color: #000000"><br /> </span><span style="color: #008080">22</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />INCREMENT </span><span style="color: #0000ff">BY</span><span style="color: #000000"> </span><span style="color: #800000; font-weight: bold">1</span><span style="color: #000000"><br /> </span><span style="color: #008080">23</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />NOMAXVALUE<br /> </span><span style="color: #008080">24</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />CACHE </span><span style="color: #800000; font-weight: bold">20</span></div> <br /> <br /> -- 扚w新增一万条用户<br /> <br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><span style="color: #008080"> 1</span><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /><span style="color: #008080">--</span><span style="color: #008080"> 扚w新增一万条用户</span><span style="color: #008080"><br /> </span><span style="color: #008080"> 2</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">CREATE</span><span style="color: #000000"> </span><span style="color: #808080">OR</span><span style="color: #000000"> </span><span style="color: #ff00ff">REPLACE</span><span style="color: #000000"> </span><span style="color: #0000ff">PROCEDURE</span><span style="color: #000000"> PROC_USER_CREATE_BAT<br /> </span><span style="color: #008080"> 3</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">AS</span><span style="color: #000000"><br /> </span><span style="color: #008080"> 4</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />    startTime </span><span style="color: #000000; font-weight: bold">VARCHAR2</span><span style="color: #000000">(</span><span style="color: #800000; font-weight: bold">32</span><span style="color: #000000">);</span><span style="color: #008080">--</span><span style="color: #008080">开始时?/span><span style="color: #008080"><br /> </span><span style="color: #008080"> 5</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #000000">    endTime </span><span style="color: #000000; font-weight: bold">VARCHAR2</span><span style="color: #000000">(</span><span style="color: #800000; font-weight: bold">32</span><span style="color: #000000">);</span><span style="color: #008080">--</span><span style="color: #008080">l束旉</span><span style="color: #008080"><br /> </span><span style="color: #008080"> 6</span><span style="color: #008080"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">BEGIN</span><span style="color: #000000"><br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />  </span><span style="color: #0000ff">SELECT</span><span style="color: #000000"> TO_CHAR(SYSDATE,</span><span style="color: #ff0000">'</span><span style="color: #ff0000">yyyy-mm-dd hh24:mi:ss:ff</span><span style="color: #ff0000">'</span><span style="color: #000000">) </span><span style="color: #0000ff">INTO</span><span style="color: #000000"> startTime </span><span style="color: #0000ff">FROM</span><span style="color: #000000"> DUAL;<br /> </span><span style="color: #008080"> 8</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />  DBMS_OUTPUT.PUT_LINE(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">Start Time: </span><span style="color: #ff0000">'</span><span style="color: #808080">||</span><span style="color: #000000">startTime);<br /> </span><span style="color: #008080"> 9</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />  </span><span style="color: #0000ff">FOR</span><span style="color: #000000"> i </span><span style="color: #808080">in</span><span style="color: #000000"> </span><span style="color: #800000; font-weight: bold">1</span><span style="color: #000000">..</span><span style="color: #800000; font-weight: bold">10000</span><span style="color: #000000"> LOOP<br /> </span><span style="color: #008080">10</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />     </span><span style="color: #0000ff">INSERT</span><span style="color: #000000"> </span><span style="color: #0000ff">INTO</span><span style="color: #000000"> T_PORTAL_USER </span><span style="color: #0000ff">VALUES</span><span style="color: #000000">(SEQ_T_PORTAL_USER.NEXTVAL,</span><span style="color: #ff0000">'</span><span style="color: #ff0000">owen</span><span style="color: #ff0000">'</span><span style="color: #808080">||</span><span style="color: #000000">i,</span><span style="color: #ff0000">'</span><span style="color: #ff0000">123456</span><span style="color: #ff0000">'</span><span style="color: #000000">,</span><span style="color: #ff0000">'</span><span style="color: #ff0000">gekunjin</span><span style="color: #ff0000">'</span><span style="color: #808080">||</span><span style="color: #000000">i,</span><span style="color: #ff0000">'</span><span style="color: #ff0000">0</span><span style="color: #ff0000">'</span><span style="color: #000000">,sysdate,</span><span style="color: #ff0000">'</span><span style="color: #ff0000">0</span><span style="color: #ff0000">'</span><span style="color: #000000">);<br /> </span><span style="color: #008080">11</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />  </span><span style="color: #0000ff">END</span><span style="color: #000000"> LOOP;<br /> </span><span style="color: #008080">12</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />  </span><span style="color: #0000ff">SELECT</span><span style="color: #000000"> TO_CHAR(SYSDATE,</span><span style="color: #ff0000">'</span><span style="color: #ff0000">yyyy-mm-dd hh24:mi:ss:ff</span><span style="color: #ff0000">'</span><span style="color: #000000">) </span><span style="color: #0000ff">INTO</span><span style="color: #000000"> endTime </span><span style="color: #0000ff">FROM</span><span style="color: #000000"> DUAL;<br /> </span><span style="color: #008080">13</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" />  DBMS_OUTPUT.PUT_LINE(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">End Time: </span><span style="color: #ff0000">'</span><span style="color: #808080">||</span><span style="color: #000000">endTime);<br /> </span><span style="color: #008080">14</span><span style="color: #000000"><img align="top" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff">END</span><span style="color: #000000"> PROC_USER_CREATE_BAT;</span></div> <img src ="http://www.tkk7.com/absolutedo/aggbug/339194.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/absolutedo/" target="_blank">absolute</a> 2010-11-27 14:41 <a href="http://www.tkk7.com/absolutedo/archive/2010/11/27/339194.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>让Apache CXF 支持传递java.sql.Timestamp和java.util.HashMapcdhttp://www.tkk7.com/absolutedo/archive/2010/11/27/339190.htmlabsoluteabsoluteSat, 27 Nov 2010 06:28:00 GMThttp://www.tkk7.com/absolutedo/archive/2010/11/27/339190.htmlhttp://www.tkk7.com/absolutedo/comments/339190.htmlhttp://www.tkk7.com/absolutedo/archive/2010/11/27/339190.html#Feedback1http://www.tkk7.com/absolutedo/comments/commentRss/339190.htmlhttp://www.tkk7.com/absolutedo/services/trackbacks/339190.html阅读全文

absolute 2010-11-27 14:28 发表评论
]]>
Policy for init Spring Container in WEB Applicationhttp://www.tkk7.com/absolutedo/archive/2010/09/13/331916.htmlabsoluteabsoluteMon, 13 Sep 2010 10:10:00 GMThttp://www.tkk7.com/absolutedo/archive/2010/09/13/331916.htmlhttp://www.tkk7.com/absolutedo/comments/331916.htmlhttp://www.tkk7.com/absolutedo/archive/2010/09/13/331916.html#Feedback0http://www.tkk7.com/absolutedo/comments/commentRss/331916.htmlhttp://www.tkk7.com/absolutedo/services/trackbacks/331916.htmlWeb应用初始化Spring容器{略

以下软g试环境为Spring,Struts1

1、通过struts1提供的插件机Ӟ采用Spring提供的ContextLoaderPlugIn

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
 <global-exceptions />
 <global-forwards />
 <message-resources parameter="com.portal.ApplicationResources" />
 <!--  通过S1提供的插件机制来初始化Spring容器Q加载Spring配置文g
 <plug-in
  className="org.springframework.web.struts.ContextLoaderPlugIn">
  <!--
   1、ContextLoaderPlugIn默认加蝲配置文g命名规则是actionServlet-servlet.xml,其中actionServlet
   是配|org.apache.struts.action.ActionServlet时指定的servlet名称
   
   2、通过配置contextConfigLocation属性来指点Spring配置文g的位|?多个配置文g可以使用 逗号","、分?;"、空? "
  -->
  <set-property property="contextConfigLocation"
   value="/WEB-INF/conf/spring-application.xml,/WEB-INF/conf/**/spring*.xml" />
 </plug-in> 
  -->
</struts-config>


2、采用Spring提供的ContextLoaderListener来初始化(应用服务器需要支持Listener,Servlet2.3版本及以?
 <context-param>
   <description>通过配置contextConfigLocation属性来指点Spring配置文g的位|?多个配置文g可以使用 逗号","、分?;"、空? "</description>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/conf/spring-application.xml /WEB-INF/conf/**/spring*.xml</param-value>
  </context-param>
 
  <listener>
   <description>通过ContextLocaderListener来初始化Spring容器Q加载Spring配置文g</description>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

3、采用load-on-startup Servlet 来初始化Spring容器
  <servlet>
   <description>
    通过load-on-startup Servlet来初始化Spring容器
    该如何Servlet 用于提供"后台"服务Q作为容器管理应用中的其他beanQ不需要响应客戯求,因此无须配置servlet-mapping
   </description>
   <servlet-name>applicationContext</servlet-name>
   <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
   <load-on-startup>0</load-on-startup>
  </servlet>



absolute 2010-09-13 18:10 发表评论
]]>
集群和分布式[Reship]http://www.tkk7.com/absolutedo/archive/2010/03/02/314282.htmlabsoluteabsoluteTue, 02 Mar 2010 06:16:00 GMThttp://www.tkk7.com/absolutedo/archive/2010/03/02/314282.htmlhttp://www.tkk7.com/absolutedo/comments/314282.htmlhttp://www.tkk7.com/absolutedo/archive/2010/03/02/314282.html#Feedback0http://www.tkk7.com/absolutedo/comments/commentRss/314282.htmlhttp://www.tkk7.com/absolutedo/services/trackbacks/314282.html集群概念
1. 两大关键Ҏ?
集群是一l协同工作的服务实体Q用以提供比单一服务实体更具扩展性与可用性的服务q_。在客户端看来,一个集就象是一个服务实体,但事实上集群׃l服务实体组成。与单一服务实体相比较,集群提供了以下两个关键特性:

·  可扩展性-Q集的性能不限于单一的服务实体,新的服务实体可以动态地加入到集,从而增强集的性能?/p>

·  高可用性-Q集通过服务实体冗余使客L免于L遇到out of service的警告。在集群中,同样的服务可以由多个服务实体提供。如果一个服务实体失败了Q另一个服务实体会接管p|的服务实体。集提供的从一个出错的服务实体恢复到另一个服务实体的功能增强了应用的可用性?/p>

2. 两大能力
Zh可扩展性和高可用性特点,集群的必d备以下两大能力:

·  负蝲均衡Q-负蝲均衡能把d比较均衡地分布到集群环境下的计算和网l资源?/p>

·  错误恢复Q-׃某种原因Q执行某个Q务的资源出现故障Q另一服务实体中执行同一d的资源接着完成d。这U由于一个实体中的资源不能工作,另一个实体中的资源透明的l完成Q务的q程叫错误恢复?/p>

负蝲均衡和错误恢复都要求各服务实体中有执行同一d的资源存在,而且对于同一d的各个资源来_执行d所需的信息视图(信息上下文)必须是一L?/p>

3. 两大技?
实现集群务必要有以下两大技术:

·  集群地址Q-集群由多个服务实体组成,集群客户端通过讉K集群的集地址获取集群内部各服务实体的功能。具有单一集群地址Q也叫单一影像Q是集群的一个基本特征。维护集地址的设|被UCؓ负蝲均衡器。负载均衡器内部负责理各个服务实体的加入和退出,外部负责集群地址向内部服务实体地址的{换。有的负载均衡器实现真正的负载均衡算法,有的只支持Q务的转换。只实现d转换的负载均衡器适用于支持ACTIVE-STANDBY的集环境,在那里,集群中只有一个服务实体工作,当正在工作的服务实体发生故障Ӟ负蝲均衡器把后来的Q务{向另外一个服务实体?/p>

·  内部通信Q-Z能协同工作、实现负载均衡和错误恢复Q集各实体间必L帔R信Q比如负载均衡器Ҏ务实体心x试信息、服务实体间d执行上下文信息的通信?/p>

h同一个集地址使得客户端能讉K集群提供的计服务,一个集地址下隐藏了各个服务实体的内部地址Q得客戯求的计算服务能在各个服务实体之间分布。内部通信是集能正常q{的基Q它使得集群h均衡负蝲和错误恢复的能力?/p>

集群分类
Linux集群主要分成三大c? 高可用集, 负蝲均衡集群Q科学计集?

高可用集? High Availability Cluster)
负蝲均衡集群(Load Balance Cluster)
U学计算集群(High Performance Computing Cluster)
================================================

具体包括Q?/p>

Linux High Availability 高可用集?nbsp;                                     
(普通两节点双机热备Q多节点HA集群QRAC, shared, share-nothing集群{?

Linux Load Balance 负蝲均衡集群                                     
 (LVS{?...)

Linux High Performance Computing 高性能U学计算集群    
 (Beowulf c集?...)

分布式存?nbsp;                                                                       
其他clinux集群             
(如Openmosix, rendering farm {?.)

详细介绍
1. 高可用集?High Availability Cluster)
常见的就?个节点做成的HA集群Q有很多通俗的不U学的名Uͼ比如"双机热备", "双机互备", "双机".
高可用集解决的是保障用L应用E序持箋对外提供服务的能力?(h意高可用集群既不是用来保护业务数据的Q保护的是用L业务E序对外不间断提供服务,把因软g/g/Zؓ造成的故障对业务的媄响降低到最程??/p>

2. 负蝲均衡集群(Load Balance Cluster)

负蝲均衡pȝQ集中所有的节点都处于活动状态,它们分摊pȝ的工作负载。一般Web服务器集、数据库集群和应用服务器集群都属于这U类型?/p>

负蝲均衡集群一般用于相应网l请求的|页服务器,数据库服务器。这U集可以在接到hӞ查接受请求较,不繁忙的服务器,q把h转到q些服务器上。从查其他服务器状态这一点上看,负蝲均衡和容错集很接近Q不同之处是数量上更多?/p>

3. U学计算集群(High Performance Computing Cluster)

高性能计算(High Perfermance Computing)集群Q简UHPC集群。这c集致力于提供单个计算机所不能提供的强大的计算能力?/p>

高性能计算分类  
 高吞吐计?High-throughput Computing)
  有一c高性能计算Q可以把它分成若q可以ƈ行的子Q务,而且各个子Q务彼此间没有什么关联。象在家搜寻外星人( SETI@HOME -- Search for Extraterrestrial Intelligence at Home Q就是这一cd应用。这一目是利用Internet上的闲置的计资源来搜寻外星人。SETI目的服务器一l数据和数据模式发给Internet上参加SETI的计节点,计算节点在给定的数据上用l定的模式进行搜索,然后搜索的l果发给服务器。服务器负责从各个计算节点q回的数据汇集成完整的数据。因U类型应用的一个共同特征是在v量数据上搜烦某些模式Q所以把q类计算UCؓ高吞吐计。所谓的Internet计算都属于这一cR按?Flynn的分c,高吞吐计属于SIMDQSingle Instruction/Multiple DataQ的范畴?/p>

 分布计算(Distributed Computing)
  另一c计刚好和高吞吐计相反,它们虽然可以l分成若qƈ行的子Q务,但是子Q务间联系很紧密,需要大量的数据交换。按照Flynn的分c,分布式的高性能计算属于MIMDQMultiple Instruction/Multiple DataQ的范畴?/p>

4. 分布式(集群Q与集群的联pM区别
分布式是指将不同的业务分布在不同的地斏V?
而集指的是几台服务器集中在一P实现同一业务?
分布式中的每一个节点,都可以做集群?
而集ƈ不一定就是分布式的?
举例Q就比如新浪|,讉K的h多了Q他可以做一个群集,前面放一个响应服务器Q后面几台服务器完成同一业务Q如果有业务讉K的时候,响应服务器看哪台服务器的负蝲不是很重Q就给哪一台去完成?
而分布式Q从H意上理解,也跟集群差不多, 但是它的l织比较松散Q不像集,有一个组l性,一台服务器垮了Q其它的服务器可以顶上来?
分布式的每一个节点,都完成不同的业务Q一个节点垮了,哪这个业务就不可讉K了?/p>

 

本文来自CSDN博客Q{载请标明出处Qhttp://blog.csdn.net/tanghongru1983/archive/2009/04/28/4130356.aspx



absolute 2010-03-02 14:16 发表评论
]]>
Myeclipse7.0注册机的源代码[Reship]http://www.tkk7.com/absolutedo/archive/2010/02/16/313155.htmlabsoluteabsoluteTue, 16 Feb 2010 01:20:00 GMThttp://www.tkk7.com/absolutedo/archive/2010/02/16/313155.html
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MyEclipseGen {
private static final String LL = "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.";

public String getSerial(String userId, String licenseNum) {
   java.util.Calendar cal 
= java.util.Calendar.getInstance();
   cal.add(
13);
   cal.add(
6-1);
   java.text.NumberFormat nf 
= new java.text.DecimalFormat("000");
   licenseNum 
= nf.format(Integer.valueOf(licenseNum));
   String verTime 
= new StringBuilder("-").append(
     
new java.text.SimpleDateFormat("yyMMdd").format(cal.getTime()))
     .append(
"0").toString();
   String type 
= "YE3MP-";
   String need 
= new StringBuilder(userId.substring(01)).append(type)
     .append(
"300").append(licenseNum).append(verTime).toString();
   String dx 
= new StringBuilder(need).append(LL).append(userId)
     .toString();
   
int suf = this.decode(dx);
   String code 
= new StringBuilder(need).append(String.valueOf(suf))
     .toString();
   
return this.change(code);
}


private int decode(String s) {
   
int i;
   
char[] ac;
   
int j;
   
int k;
   i 
= 0;
   ac 
= s.toCharArray();
   j 
= 0;
   k 
= ac.length;
   
while (j < k) {
    i 
= (31 * i) + ac[j];
    j
++;
   }

   
return Math.abs(i);
}


private String change(String s) {
   
byte[] abyte0;
   
char[] ac;
   
int i;
   
int k;
   
int j;
   abyte0 
= s.getBytes();
   ac 
= new char[s.length()];
   i 
= 0;
   k 
= abyte0.length;
   
while (i < k) {
    j 
= abyte0[i];
    
if ((j >= 48&& (j <= 57)) {
     j 
= (((j - 48+ 5% 10+ 48;
    }
 else if ((j >= 65&& (j <= 90)) {
     j 
= (((j - 65+ 13% 26+ 65;
    }
 else if ((j >= 97&& (j <= 122)) {
     j 
= (((j - 97+ 13% 26+ 97;
    }

    ac[i] 
= (char) j;
    i
++;
   }

   
return String.valueOf(ac);
}


public MyEclipseGen() {
   
super();
}


public static void main(String[] args) {
   
try {
    System.out.println(
"please input register name:");
    BufferedReader reader 
= new BufferedReader(new InputStreamReader(
      System.in));
    String userId 
= null;
    userId 
= reader.readLine();
    MyEclipseGen myeclipsegen 
= new MyEclipseGen();
    String res 
= myeclipsegen.getSerial(userId, "5");
    System.out.println(
"Serial:" + res);
    reader.readLine();
   }
 catch (IOException ex) {
   }

}

}


注册ҎQ?br /> window -> preferences -> myeclipse -> subscription

 



absolute 2010-02-16 09:20 发表评论
]]>
Hibernate Study Note 1http://www.tkk7.com/absolutedo/archive/2010/01/09/308863.htmlabsoluteabsoluteSat, 09 Jan 2010 11:08:00 GMThttp://www.tkk7.com/absolutedo/archive/2010/01/09/308863.htmlhttp://www.tkk7.com/absolutedo/comments/308863.htmlhttp://www.tkk7.com/absolutedo/archive/2010/01/09/308863.html#Feedback0http://www.tkk7.com/absolutedo/comments/commentRss/308863.htmlhttp://www.tkk7.com/absolutedo/services/trackbacks/308863.html 

Hibernate学习W记

1?/span>Hibernate核心cM接口    

1-1.Configurationc?/span>

      ConfigurationcLHibernate的入口,它负责配|和启动Hibernate,Hibernate框架通过Configuration实例加蝲配置文g信息(hibernate.cfg.xml),然后d指定对象关系映射文g(bean.hbm.xml)的内容ƈ创徏SessionFactory.

1-2.SessionFactory接口

       SessionFactory接口负责初始?/span>Hibernate,一?/span>SessionFactory实例对应一个数据存储源(一般就是指一个数据库)。应用程序从SessionFactory中获?/span>Session实例?/span>SessionFactoryh以下特点Q?/span>

       1)    U程安全Q即同一?/span> SessionFactory实例可以被应?/span> 的多个线E共享?/span>

       2)    它是重量U的 Q因为它需要一个很大的~存Q用来存N定义?/span>SQL语句以及映射元数据等?/span>

所以说 Q如果一个应用程序中只访问一个数据库 Q则只需要创Z个全局?/span> SessionFactory实例?/span>

1-3.Session 接口

    Session?/span>Hibernate中应用最频繁的接口?/span>Session也被UCؓ持久化管理器 Q它负责理所有与持久化相关的操作Q如存储、更新、删除和加蝲对象{?/span>Session接口h以下特点Q?/span>

    1)    单线E,非共享的对象。线E不安全Q在设计软g架构时候,应该避免多个U程׃n同一?/span>session实例?/span>

    2)    Session 实例是轻量的,它的创徏和销毁不需要消耗太多的资源。可以ؓ每个请分配一?/span>Session实例Q在每次hq程汇d时创建和销?/span> Session实例?/span>

    3)    Session有一个缓存,它存攑ֽ前工作单元加载的对象?/span>Session的缓存被UCؓHibernate的一U缓存?/span>

1-4.Transaction接口

    Transaction接口?/span> Hibernate框架的事务接口。它对底层的事务接口做了装Q包括:JDBC API?/span>JTA.q样使得Hibernate应用可以通过一致的Transaction接口来申明事务边界,q有助于应用E序再不同的环境和容器中UL?/span>

1-5.Query?/span>Criteria接口

    它们?/span> Hibernate的查询接口,用于从数据存储源查询对象及控制执行查询的q程?/span>Query包装了一?/span> HQL(Hibernate Query Language)Q?/span>Criteria接口完全装了基本字W串形式的查询语句,?/span>Query更加面向对象Q?/span>Criteria接口擅长于执行动态查询?/span>

2?/span>Hibernate中常用的事务隔离U别

帔R

?/span>

说明

TRANSACTION_NONE 

0

不支持事?/span>

TRANSACTION_READ_UNCOMMITTED

1

指示可以发生脏读Q?/span>dirty readQ、不可重复读和虚读(phantom readQ的帔R。此U别允许被某一事务更改的行在已提交该行所有更改之前被另一个事务读取(“脏读”Q。如果所有更攚w被回滚,则第二个事务获取无效的行?/span>

TRANSACTION_READ_COMMITTED

2

指示不可以发生脏ȝ帔RQ不可重复读和虚d以发生。此U别只禁止事务读取其中带有未提交更改的行?/span>

TRANSACTION_REPEATABLE_READ

4

指示不可以发生脏d不可重复ȝ帔RQ虚d以发生。此U别止事务d带有未提交更改的行,它还止q种情况Q一个事务读取某一行,而另一个事务更改该行,W一个事务重新读取该行,q在W二ơ读取时获得不同的|“不可重复?#8221;Q?/span>

TRANSACTION_SERIALIZABLE

8

指示不可以发生脏诅R不可重复读和虚ȝ帔R。此U别包括TRANSACTION_REPEATABLE_READ 中禁止的事项Q同时还止出现q种情况Q某一事务d所有满?/span> WHERE 条g的行Q另一个事务插入一个满?/span> WHERE 条g的行Q第一个事务重新读取满相同条件的行,q在W二ơ读取时获得额外?#8220;?#8221;行?/span>

3?/span>Hibernate中实例的状?/span>

3-1Q时状?/span>

       该实例从未与M持久化上下文兌q。它没有持久化标识(相当于主键|Q时状态下的对象有如下特征?/span>

1Q?span style="font: 7pt 'Times New Roman'">    不处?/span>Session~存中,也可以说不被M一?/span>Session

2Q?span style="font: 7pt 'Times New Roman'">    在数据库中没有对应的记录

在以下情况下Q?/span>Java对象q入临时状?/span>

1Q?nbsp;当通过new语句刚创Z?/span>Java对象Q它处于临时状态,此时不和数据库中的Q何记录对应?/span>

2Q?nbsp;Session?/span>delete()Ҏ能一个持久化或时脱对象{换ؓ临时对象。对于脱对象,delete()Ҏ从数据库中删除与它对应的记录Qƈ且把它从Session~存中删除?/span>

3-2Q持久化状?/span>

      该实例目前与某个持久化上下文有关联,它拥有持久化标识Q相当于主键|Qƈ且可能在数据库汇L一个对应的行。对于某一个特定的持久化上下文Q?/span>Hibernate保证标识?/span>Java标识Q其g表对应在内存中的位置Q等仗持久化对象有以下特征?/span>

1Q?nbsp;位于一?/span>Session实例的缓存中Q也可以_持久化对象L被一?/span>Session实例兌?/span>

2Q?nbsp;持久化对象和数据库中的相兌录对应?/span>

3Q?nbsp;Session在清理缓存时Q会Ҏ持久化对象的属性变化,来同步更新数据库?/span>

Session的许多方法都能够触发Java对象q入持久化状态?/span>

4Q?nbsp;Session?/span>save()的方法能够把临时对象转变成持久化对象?/span>

5Q?nbsp;Session?/span>load()?/span>get()Ҏq回的对象L处于持久化状态?/span>

6Q?nbsp;Querylist()Ҏq回?/span>list集合中存攄都是持久化对象?/span>

7Q?nbsp;Session?/span>update()?/span>saveOrUpdate()?/span>lock()Ҏ使脱对象{变ؓ持久化对象?/span>

当一个持久化对象兌一个时对象时Q在允许U联保存的情况下Q?/span>Session在清理缓存时会把q个临时对象也{变成持久化对象?/span>Hibernate保证在同一?/span>Session实例的缓存中Q数据库表中的每条记录只对应唯一的持久化对象Q也是说在一?/span>Session?/span>load/get同一?/span>OID得到 的是相同的对象?/span>

3-3Q脱状?/span>

            实例曄与某个持久化上下文发生过兌Q不q那个上下文被关闭了Q或者这个实例是被序列化(serialize)到另外的q程。它拥有持久化标识,q且在数据库中可能存在一个对应的行。对于脱状态的实例Q?/span>Hibernate不保证Q何持久化标识?/span>Java标识的关pR?/span>

q对象h以下特征?/span>

1Q?span style="font: 7pt 'Times New Roman'">    不再位于Session的缓存中Q也可以_q对象不被Session兌?/span>

2Q?span style="font: 7pt 'Times New Roman'">    q对象是有持久化对象{变过来的Q因此在数据库中可能q存在与它对应的记录(前提条g是没有其他程序删除了q条记录)?/span>

3Q?span style="font: 7pt 'Times New Roman'">    q对象与时对象的相同指出在于两者都不被Session兌Q因?/span>Hibernate不会保证他们属性变化与数据库保持同步。脱对象与临时对象的区别在于前者是由持久化对象转变q来的,因此可能在书库中q存在对应的记录Q而后者在数据库中是没有对应的记录的?/span>

Session的以下方法持久化对象{变成q对象.

1)      当调?/span>Session?/span>close()ҎӞSession 的缓存被清空Q缓存中的所有持久化对象都变对象,如果在应用程序中没有引用变量引用q些q对象Q他们就会结束生命周期?/span>

2)      Session?/span>evict()Ҏ能够从缓存中删除一个持久化对象Q它变状态,?/span>Session的缓存中保存了大量的持久化对象时Q会消耗许多内存空_Z提高性能Q可以考虑调用evict()ҎQ从~存中删除一些持久化对象。但是多数情况下不推荐用该ҎQ而应该通过查询语言Q或者显C的D来控制对象图的深度?/span>

 



absolute 2010-01-09 19:08 发表评论
]]>
Rational Rose Enterprise Edition 2003 安装破解步骤[Reship]http://www.tkk7.com/absolutedo/archive/2009/10/25/299641.htmlabsoluteabsoluteSun, 25 Oct 2009 00:29:00 GMThttp://www.tkk7.com/absolutedo/archive/2009/10/25/299641.htmlhttp://www.tkk7.com/absolutedo/comments/299641.htmlhttp://www.tkk7.com/absolutedo/archive/2009/10/25/299641.html#Feedback1http://www.tkk7.com/absolutedo/comments/commentRss/299641.htmlhttp://www.tkk7.com/absolutedo/services/trackbacks/299641.html
     1.安装Rose?默认是需要许可证书的..M载个破解?.我上传了破解文g..点击q里下蝲Rose 2003破解

     2.先用破解压羃包里?rational.exeQlmgrd.exe 覆盖C?\安装目录的Rartional\commen\?br />
     3.然后C本打开 license.dat, 修改里面?SERVER yourPC ANY  DAEMON rational "C:\Program Files\Rational\Common\rational.exe"
     Ҏ SERVER 你的机器?ANY  DAEMON rational "你的安装目录\rational.exe" ,拯到Common目录?.

    4. Flexlm.cpl拯到C:\winnt\system32\下, 在控刉杉Kq行 FlexLm License ManagerQ?nbsp;  

    q行? ?Setup 面板配置文g路径Qlmgrd.exe -> 你的安装目录 \Common\lmgrd.exe, ?License File Z改过?license.dat ...



     5.在Control面板点击StartQ如果成功的话点击Status按钮显C?你的机器名:license server UP (MASTER) 说明成功?
     p|的话重启一下FlexLm License Manager没问题了?nbsp;



     6.如果弹出对话框License Key Administrator Wizard? 选定Point to a Rational License Server to get my licensesQ单M一步,
Server Name文本框中填写你的机器?可能已经填好)Q单d成?(成功的话会出C屏的licenses) 

注意Q本文{臻Ihttp://www.cnblogs.com/lixianhuei/archive/2006/01/09/313644.html

absolute 2009-10-25 08:29 发表评论
]]>
一道SQL面试?/title><link>http://www.tkk7.com/absolutedo/archive/2009/08/17/291432.html</link><dc:creator>absolute</dc:creator><author>absolute</author><pubDate>Mon, 17 Aug 2009 02:14:00 GMT</pubDate><guid>http://www.tkk7.com/absolutedo/archive/2009/08/17/291432.html</guid><wfw:comment>http://www.tkk7.com/absolutedo/comments/291432.html</wfw:comment><comments>http://www.tkk7.com/absolutedo/archive/2009/08/17/291432.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/absolutedo/comments/commentRss/291432.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/absolutedo/services/trackbacks/291432.html</trackback:ping><description><![CDATA[有这样两个表Q?br /> table_a:<br /> <br /> id        name        val <br /> 1          aaa          30 <br /> 2          aaa          40 <br /> 3          aaa          50 <br /> 1          bbb         35 <br /> 2          bbb         45 <br /> 3          bbb         55 <br /> <br /> table_b: <br /> name        val1        val2        val3 <br /> aaa            30          40          50 <br /> bbb           35          45          55 <br /> <br /> L一个SQL语句实现table_a到table_b的{化?br /> <br /> <br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #008080"> 1</span><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff">create</span><span style="color: #000000"> </span><span style="color: #0000ff">table</span><span style="color: #000000"> tb(id </span><span style="font-weight: bold; color: #000000">int</span><span style="color: #000000">, name </span><span style="font-weight: bold; color: #000000">varchar</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">10</span><span style="color: #000000">), val </span><span style="font-weight: bold; color: #000000">int</span><span style="color: #000000">)<br /> </span><span style="color: #008080"> 2</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">insert</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> tb </span><span style="color: #0000ff">values</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">1</span><span style="color: #000000"> , </span><span style="color: #ff0000">'</span><span style="color: #ff0000">aaa</span><span style="color: #ff0000">'</span><span style="color: #000000"> , </span><span style="font-weight: bold; color: #800000">30</span><span style="color: #000000"> )<br /> </span><span style="color: #008080"> 3</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">insert</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> tb </span><span style="color: #0000ff">values</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">2</span><span style="color: #000000"> , </span><span style="color: #ff0000">'</span><span style="color: #ff0000">aaa</span><span style="color: #ff0000">'</span><span style="color: #000000"> , </span><span style="font-weight: bold; color: #800000">40</span><span style="color: #000000"> )<br /> </span><span style="color: #008080"> 4</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">insert</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> tb </span><span style="color: #0000ff">values</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">3</span><span style="color: #000000"> , </span><span style="color: #ff0000">'</span><span style="color: #ff0000">aaa</span><span style="color: #ff0000">'</span><span style="color: #000000"> , </span><span style="font-weight: bold; color: #800000">50</span><span style="color: #000000"> )<br /> </span><span style="color: #008080"> 5</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">insert</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> tb </span><span style="color: #0000ff">values</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">1</span><span style="color: #000000"> , </span><span style="color: #ff0000">'</span><span style="color: #ff0000">bbb</span><span style="color: #ff0000">'</span><span style="color: #000000"> , </span><span style="font-weight: bold; color: #800000">35</span><span style="color: #000000"> )<br /> </span><span style="color: #008080"> 6</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">insert</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> tb </span><span style="color: #0000ff">values</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">2</span><span style="color: #000000"> , </span><span style="color: #ff0000">'</span><span style="color: #ff0000">bbb</span><span style="color: #ff0000">'</span><span style="color: #000000"> , </span><span style="font-weight: bold; color: #800000">45</span><span style="color: #000000"> )<br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">insert</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> tb </span><span style="color: #0000ff">values</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">3</span><span style="color: #000000"> , </span><span style="color: #ff0000">'</span><span style="color: #ff0000">bbb</span><span style="color: #ff0000">'</span><span style="color: #000000"> , </span><span style="font-weight: bold; color: #800000">55</span><span style="color: #000000"> )<br /> </span><span style="color: #008080"> 8</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">go</span><span style="color: #000000"><br /> </span><span style="color: #008080"> 9</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080">10</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">sql 2000静态,指ID只有1,2,3</span><span style="color: #008080"><br /> </span><span style="color: #008080">11</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">select</span><span style="color: #000000"> name , <br /> </span><span style="color: #008080">12</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />       </span><span style="color: #ff00ff">sum</span><span style="color: #000000">(</span><span style="color: #ff00ff">case</span><span style="color: #000000"> id </span><span style="color: #0000ff">when</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">1</span><span style="color: #000000"> </span><span style="color: #0000ff">then</span><span style="color: #000000"> val </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">0</span><span style="color: #000000"> </span><span style="color: #0000ff">end</span><span style="color: #000000">) </span><span style="color: #ff0000">[</span><span style="color: #ff0000">val1</span><span style="color: #ff0000">]</span><span style="color: #000000">,<br /> </span><span style="color: #008080">13</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />       </span><span style="color: #ff00ff">sum</span><span style="color: #000000">(</span><span style="color: #ff00ff">case</span><span style="color: #000000"> id </span><span style="color: #0000ff">when</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">2</span><span style="color: #000000"> </span><span style="color: #0000ff">then</span><span style="color: #000000"> val </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">0</span><span style="color: #000000"> </span><span style="color: #0000ff">end</span><span style="color: #000000">) </span><span style="color: #ff0000">[</span><span style="color: #ff0000">val2</span><span style="color: #ff0000">]</span><span style="color: #000000">,<br /> </span><span style="color: #008080">14</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />       </span><span style="color: #ff00ff">sum</span><span style="color: #000000">(</span><span style="color: #ff00ff">case</span><span style="color: #000000"> id </span><span style="color: #0000ff">when</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">3</span><span style="color: #000000"> </span><span style="color: #0000ff">then</span><span style="color: #000000"> val </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">0</span><span style="color: #000000"> </span><span style="color: #0000ff">end</span><span style="color: #000000">) </span><span style="color: #ff0000">[</span><span style="color: #ff0000">val3</span><span style="color: #ff0000">]</span><span style="color: #000000"><br /> </span><span style="color: #008080">15</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">from</span><span style="color: #000000"> tb<br /> </span><span style="color: #008080">16</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">group</span><span style="color: #000000"> </span><span style="color: #0000ff">by</span><span style="color: #000000"> name<br /> </span><span style="color: #008080">17</span><span style="color: #000000"><img id="Codehighlighter1_514_705_Open_Image" onclick="this.style.display='none'; Codehighlighter1_514_705_Open_Text.style.display='none'; Codehighlighter1_514_705_Closed_Image.style.display='inline'; Codehighlighter1_514_705_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_514_705_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_514_705_Closed_Text.style.display='none'; Codehighlighter1_514_705_Open_Image.style.display='inline'; Codehighlighter1_514_705_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span id="Codehighlighter1_514_705_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_514_705_Open_Text"><span style="color: #008080">/*</span><span style="color: #008080"><br /> </span><span style="color: #008080">18</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />name       val1        val2        val3        <br /> </span><span style="color: #008080">19</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />---------- ----------- ----------- ----------- <br /> </span><span style="color: #008080">20</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />aaa        30          40          50<br /> </span><span style="color: #008080">21</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />bbb        35          45          55<br /> </span><span style="color: #008080">22</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">23</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />Q所影响的行Cؓ 2 行)<br /> </span><span style="color: #008080">24</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" /></span><span style="color: #008080">*/</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">25</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080">26</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">sql 2000动态,指ID不确?/span><span style="color: #008080"><br /> </span><span style="color: #008080">27</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">declare</span><span style="color: #000000"> </span><span style="color: #008000">@sql</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #000000">varchar</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">8000</span><span style="color: #000000">)<br /> </span><span style="color: #008080">28</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">set</span><span style="color: #000000"> </span><span style="color: #008000">@sql</span><span style="color: #000000"> </span><span style="color: #808080">=</span><span style="color: #000000"> </span><span style="color: #ff0000">'</span><span style="color: #ff0000">select name </span><span style="color: #ff0000">'</span><span style="color: #000000"><br /> </span><span style="color: #008080">29</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">select</span><span style="color: #000000"> </span><span style="color: #008000">@sql</span><span style="color: #000000"> </span><span style="color: #808080">=</span><span style="color: #000000"> </span><span style="color: #008000">@sql</span><span style="color: #000000"> </span><span style="color: #808080">+</span><span style="color: #000000"> </span><span style="color: #ff0000">'</span><span style="color: #ff0000"> , sum(case id when </span><span style="color: #ff0000">'''</span><span style="color: #000000"> </span><span style="color: #808080">+</span><span style="color: #000000"> </span><span style="color: #ff00ff">cast</span><span style="color: #000000">(id </span><span style="color: #0000ff">as</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #000000">varchar</span><span style="color: #000000">) </span><span style="color: #808080">+</span><span style="color: #000000"> </span><span style="color: #ff0000">'''</span><span style="color: #ff0000"> then val else 0 end) [val</span><span style="color: #ff0000">'</span><span style="color: #000000"> </span><span style="color: #808080">+</span><span style="color: #000000"> </span><span style="color: #ff00ff">cast</span><span style="color: #000000">(id </span><span style="color: #0000ff">as</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #000000">varchar</span><span style="color: #000000">) </span><span style="color: #808080">+</span><span style="color: #000000"> </span><span style="color: #ff0000">'</span><span style="color: #ff0000">]</span><span style="color: #ff0000">'</span><span style="color: #000000"><br /> </span><span style="color: #008080">30</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">from</span><span style="color: #000000"> (</span><span style="color: #0000ff">select</span><span style="color: #000000"> </span><span style="color: #0000ff">distinct</span><span style="color: #000000"> id </span><span style="color: #0000ff">from</span><span style="color: #000000"> tb) </span><span style="color: #0000ff">as</span><span style="color: #000000"> a<br /> </span><span style="color: #008080">31</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">set</span><span style="color: #000000"> </span><span style="color: #008000">@sql</span><span style="color: #000000"> </span><span style="color: #808080">=</span><span style="color: #000000"> </span><span style="color: #008000">@sql</span><span style="color: #000000"> </span><span style="color: #808080">+</span><span style="color: #000000"> </span><span style="color: #ff0000">'</span><span style="color: #ff0000"> from tb group by name</span><span style="color: #ff0000">'</span><span style="color: #000000"><br /> </span><span style="color: #008080">32</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">exec</span><span style="color: #000000">(</span><span style="color: #008000">@sql</span><span style="color: #000000">) <br /> </span><span style="color: #008080">33</span><span style="color: #000000"><img id="Codehighlighter1_1004_1180_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1004_1180_Open_Text.style.display='none'; Codehighlighter1_1004_1180_Closed_Image.style.display='inline'; Codehighlighter1_1004_1180_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1004_1180_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1004_1180_Closed_Text.style.display='none'; Codehighlighter1_1004_1180_Open_Image.style.display='inline'; Codehighlighter1_1004_1180_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span id="Codehighlighter1_1004_1180_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_1004_1180_Open_Text"><span style="color: #008080">/*</span><span style="color: #008080"><br /> </span><span style="color: #008080">34</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />name       val1        val2        val3        <br /> </span><span style="color: #008080">35</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />---------- ----------- ----------- ----------- <br /> </span><span style="color: #008080">36</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />aaa        30          40          50<br /> </span><span style="color: #008080">37</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />bbb        35          45          55<br /> </span><span style="color: #008080">38</span><span style="color: #008080"><img src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" /></span><span style="color: #008080">*/</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">39</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080">40</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080">41</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">drop</span><span style="color: #000000"> </span><span style="color: #0000ff">table</span><span style="color: #000000"> tb<br /> </span><span style="color: #008080">42</span><span style="color: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> <br /> <br /> <img src ="http://www.tkk7.com/absolutedo/aggbug/291432.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/absolutedo/" target="_blank">absolute</a> 2009-08-17 10:14 <a href="http://www.tkk7.com/absolutedo/archive/2009/08/17/291432.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>sql?with rollup 、with cube、grouping l计函数用法 http://www.tkk7.com/absolutedo/archive/2009/08/17/291426.htmlabsoluteabsoluteMon, 17 Aug 2009 01:51:00 GMThttp://www.tkk7.com/absolutedo/archive/2009/08/17/291426.htmlhttp://www.tkk7.com/absolutedo/comments/291426.htmlhttp://www.tkk7.com/absolutedo/archive/2009/08/17/291426.html#Feedback0http://www.tkk7.com/absolutedo/comments/commentRss/291426.htmlhttp://www.tkk7.com/absolutedo/services/trackbacks/291426.htmlSQL code
with rollup ?/span>with cube?/span>grouping CUBE ?ROLLUP 之间的区别在于: CUBE 生成的结果集昄了所选列中值的所有组合的聚合? ROLLUP 生成的结果集昄了所选列中值的某一层次l构的聚合? grouping: 当用 CUBE ?ROLLUP q算W添加行Ӟ附加的列输出gؓ1Q当所d的行不是?CUBE ?ROLLUP 产生Ӟ附加列gؓ0? --例如 DECLARE @T TABLE(名称 VARCHAR(1) , 出版?VARCHAR(10), h1 INT, h2 INT) INSERT @T SELECT 'a', '北京', 11, 22 UNION ALL SELECT 'a', '四川', 22, 33 UNION ALL SELECT 'b', '四川', 12, 23 UNION ALL SELECT 'b', '北京', 10, 20 UNION ALL SELECT 'b', '昆明', 20, 30 SELECT 名称, 出版? SUM(h1) AS h1, SUM(h2) AS h2, GROUPING(名称) AS CHECK名称, GROUPING(出版? AS CHECK出版? FROM @T GROUP BY 名称,出版?WITH CUBE /* 名称 出版? h1 h2 CHECK名称 CHECK出版? ---- ---------- ----------- ----------- ------- -------- a 北京 11 22 0 0 a 四川 22 33 0 0 a NULL 33 55 0 1 b 北京 10 20 0 0 b 昆明 20 30 0 0 b 四川 12 23 0 0 b NULL 42 73 0 1 NULL NULL 75 128 1 1 NULL 北京 21 42 1 0 NULL 昆明 20 30 1 0 NULL 四川 34 56 1 0 Q所影响的行Cؓ 11 行) */ --分析 /*group by 两列Q名U有两个cdA,B;所有由CUBEq算而生成行的是 名称 出版? h1 h2 CHECK名称 CHECK出版? ---- ---------- ----------- ----------- ------- -------- a NULL 33 55 0 1 b NULL 42 73 0 1 出版商有三个cdQ所有由CUBEq算而生成行的是 名称 出版? h1 h2 CHECK名称 CHECK出版? ---- ---------- ----------- ----------- ------- -------- NULL 北京 21 42 1 0 NULL 昆明 20 30 1 0 NULL 四川 34 56 1 0 以及 NULL NULL 75 128 1 1 */ SELECT 名称, 出版? SUM(h1) AS h1, SUM(h2) AS h2 FROM @T GROUP BY 名称,出版?WITH ROLLUP /* 名称 出版? h1 h2 ---- ---------- ----------- ----------- a 北京 11 22 a 四川 22 33 a NULL 33 55 b 北京 10 20 b 昆明 20 30 b 四川 12 23 b NULL 42 73 NULL NULL 75 128 */


absolute 2009-08-17 09:51 发表评论
]]>
վ֩ģ壺 ϺɫϺҳa| ĻƷѾþ | ĻӰӾƷ| ѹվ߹ۿ| AVһһ| ˾þô߽ӰԺ| av벻һ| avƷɫ߿| 鶹ۺ뾫Ʒ| ĻѸ| 99ƷƵ߹ۿר| 51ҹƷƵ| Ʒާѡ2021| 77777ҹþö| Ƶ߹ۿվ| AV뾫ƷˮţӰ| þþþAVվ| ݺݾþѹۿ| ߹ۿëƬ| 2019Ļmvѿ| | 91Ƶ| ˾ƷƵҳȫ| þþƷ| ܻƺ۵վ| þþþþþþþþѾƷ| ˸߹ۿƵ| ާѡžƷ| ޾Ʒ㶮| av͵߹ۿ| þþƷav18 | žѹۿ嶯4| 91þþƷһ| һ| ߹ۿavվ| ͤͤѸ| ¼Ƶѿ| һƵ| ¼Ƶѿ| ޾Ʒһ| ѧŮëƬƵ|