锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品久久久久久久一区探花,在线观看精品自拍私拍,亚洲精品一区二区在线播放∴http://www.aygfsteel.com/koradji/category/38075.htmlzh-cnTue, 24 Apr 2012 16:54:17 GMTTue, 24 Apr 2012 16:54:17 GMT60鏌ヨ琛ㄤ腑閲嶅鎴栦笉閲嶅鐨勮褰曪紝瑕佹眰鏄劇ず鎵鏈夊瓧孌?/title><link>http://www.aygfsteel.com/koradji/articles/375106.html</link><dc:creator>koradji</dc:creator><author>koradji</author><pubDate>Wed, 18 Apr 2012 06:46:00 GMT</pubDate><guid>http://www.aygfsteel.com/koradji/articles/375106.html</guid><wfw:comment>http://www.aygfsteel.com/koradji/comments/375106.html</wfw:comment><comments>http://www.aygfsteel.com/koradji/articles/375106.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/koradji/comments/commentRss/375106.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/koradji/services/trackbacks/375106.html</trackback:ping><description><![CDATA[<div>1. 鎵撳紑閲嶅璁板綍鐨勫崟涓瓧孌碉細<br />select <span style="color: red;">distinct</span> name from table<br />2. 鎵撳紑閲嶅璁板綍鐨勬墍鏈夊瓧孌靛鹼細<br />select  * from table where fid in(select <span style="color: red;">min</span>(fid) from table group by name)<br />鍋囧畾錛歯ame瀛楁鍖呭惈閲嶅鍊?br />3. 鎵撳紑閲嶅浠繪剰嬈℃暟鐨勬墍鏈夎褰曪細<br />select * from table where name in(select name from table group by name <span style="color: red;">having count</span>(name)=1)<br /></div><img src ="http://www.aygfsteel.com/koradji/aggbug/375106.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/koradji/" target="_blank">koradji</a> 2012-04-18 14:46 <a href="http://www.aygfsteel.com/koradji/articles/375106.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>db2涓殑鐩稿叧瀛愭煡璇?/title><link>http://www.aygfsteel.com/koradji/articles/301690.html</link><dc:creator>koradji</dc:creator><author>koradji</author><pubDate>Mon, 09 Nov 2009 06:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/koradji/articles/301690.html</guid><wfw:comment>http://www.aygfsteel.com/koradji/comments/301690.html</wfw:comment><comments>http://www.aygfsteel.com/koradji/articles/301690.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/koradji/comments/commentRss/301690.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/koradji/services/trackbacks/301690.html</trackback:ping><description><![CDATA[<p>Correlated Subqueries<br /> A subquery that is allowed to refer to any of the previously mentioned tables is known as a correlated subquery. We also say that the subquery has a correlated reference to a table in the main query. </p> <p>The following example uses an uncorrelated subquery to list the employee number and name of employees in department 'A00' with a salary greater than the average salary of the department: </p> <p> <br />      SELECT EMPNO, LASTNAME<br />         FROM EMPLOYEE<br />         WHERE WORKDEPT = 'A00'<br />           AND SALARY > (SELECT AVG(SALARY)<br />                            FROM EMPLOYEE<br />                            WHERE WORKDEPT = 'A00')</p> <p>This statement produces the following result: </p> <p> EMPNO  LASTNAME<br />  ------ ---------------<br />  000010 HAAS<br />  000110 LUCCHESSI</p> <p>If you want to know the average salary for every department, the subquery needs to be evaluated once for every department. You can do this through the correlation capability of SQL, which permits you to write a subquery that is executed repeatedly, once for each row of the table identified in the outer-level query. </p> <p>The following example uses a correlated subquery to list all the employees whose salary is higher than the average salary of their department: </p> <p> <br />      SELECT E1.EMPNO, E1.LASTNAME, E1.WORKDEPT<br />         FROM EMPLOYEE E1<br />         WHERE SALARY > (SELECT AVG(SALARY) <br />                            FROM EMPLOYEE E2<br />                            WHERE E2.WORKDEPT = E1.WORKDEPT)<br />         ORDER BY E1.WORKDEPT</p> <p>In this query, the subquery is evaluated once for every department. The result is: </p> <p>     EMPNO  LASTNAME        WORKDEPT<br />      ------ --------------- --------<br />      000010 HAAS            A00     <br />      000110 LUCCHESSI       A00     <br />      000030 KWAN            C01     <br />      000060 STERN           D11     <br />      000150 ADAMSON         D11     <br />      000170 YOSHIMURA       D11     <br />      000200 BROWN           D11     <br />      000220 LUTZ            D11     <br />      000070 PULASKI         D21     <br />      000240 MARINO          D21     <br />      000270 PEREZ           D21     <br />      000090 HENDERSON       E11     <br />      000280 SCHNEIDER       E11     <br />      000100 SPENSER         E21     <br />      000330 LEE             E21     <br />      000340 GOUNOT          E21     </p> <p>To write a query with a correlated subquery, use the same basic format of an ordinary outer query with a subquery. However, in the FROM clause of the outer query, just after the table name, place a correlation name. The subquery may then contain column references qualified by the correlation name. For example, if E1 is a correlation name, then E1.WORKDEPT means the WORKDEPT value of the current row of the table in the outer query. The subquery is (conceptually) reevaluated for each row of the table in the outer query. </p> <p>By using a correlated subquery, you let the system do the work for you and reduce the amount of code you need to write within your application. </p> <p>Unqualified correlated references are allowed in DB2. For example, the table EMPLOYEE has a column named LASTNAME, but the table SALES has a column named SALES_PERSON, and no column named LASTNAME. </p> <p> <br />      SELECT LASTNAME, FIRSTNME, COMM <br />         FROM EMPLOYEE <br />         WHERE 3 > (SELECT AVG(SALES)<br />                       FROM SALES<br />                       WHERE LASTNAME = SALES_PERSON)</p> <p>In this example, the system checks the innermost FROM clause for a LASTNAME column. Not finding one, it then checks the next innermost FROM clause (which in this case is the outer FROM clause). While not always necessary, qualifying correlated references is recommended to improve the readability of the query and to ensure that you are getting the result that you intend. </p> <p><br /> Implementing a Correlated Subquery<br /> When would you want to use a correlated subquery? The use of a column function is sometimes a clue. </p> <p>Let's say you want to list the employees whose level of education is higher than the average for their department. </p> <p>First, you must determine the select-list items. The problem says "List the employees". This implies that LASTNAME from the EMPLOYEE table should be sufficient to uniquely identify employees. The problem also states the level of education (EDLEVEL) and the employees' departments (WORKDEPT) as conditions. While the problem does not explicitly ask for columns to be displayed, including them in the select-list will help illustrate the solution. A part of the query can now be constructed: </p> <p>     SELECT LASTNAME, WORKDEPT, EDLEVEL<br />         FROM EMPLOYEE</p> <p>Next, a search condition (WHERE clause) is needed. The problem statement says, "...whose level of education is higher than the average for that employee's department". This means that for every employee in the table, the average education level for that employee's department must be computed. This statement fits the description of a correlated subquery. Some unknown property (the average level of education of the current employee's department) is being computed for each row. A correlation name is needed for the EMPLOYEE table: </p> <p>     SELECT LASTNAME, WORKDEPT, EDLEVEL<br />         FROM EMPLOYEE E1</p> <p>The subquery needed is simple. It computes the average level of education for each department. The complete SQL statement is: </p> <p>     SELECT LASTNAME, WORKDEPT, EDLEVEL<br />         FROM EMPLOYEE E1<br />         WHERE EDLEVEL > (SELECT AVG(EDLEVEL)<br />                             FROM EMPLOYEE  E2<br />                             WHERE E2.WORKDEPT = E1.WORKDEPT)</p> <p>The result is: </p> <p>     LASTNAME        WORKDEPT EDLEVEL<br />      --------------- -------- -------<br />      HAAS            A00           18<br />      KWAN            C01           20<br />      PULASKI         D21           16<br />      HENDERSON       E11           16<br />      LUCCHESSI       A00           19<br />      PIANKA          D11           17<br />      SCOUTTEN        D11           17<br />      JONES           D11           17<br />      LUTZ            D11           18<br />      MARINO          D21           17<br />      JOHNSON         D21           16<br />      SCHNEIDER       E11           17<br />      MEHTA           E21           16<br />      GOUNOT          E21           16</p> <p>Suppose that instead of listing the employee's department number, you list the department name. The information you need (DEPTNAME) is in a separate table (DEPARTMENT). The outer-level query that defines a correlation variable can also be a join query (see Selecting Data from More Than One Table for details). </p> <p>When you use joins in an outer-level query, list the tables to be joined in the FROM clause, and place the correlation name next to the appropriate table name. </p> <p>To modify the query to list the department's name instead of its number, replace WORKDEPT by DEPTNAME in the select-list. The FROM clause must now also include the DEPARTMENT table, and the WHERE clause must express the appropriate join condition. </p> <p>This is the modified query: </p> <p>     SELECT LASTNAME, DEPTNAME, EDLEVEL<br />         FROM EMPLOYEE E1, DEPARTMENT<br />         WHERE E1.WORKDEPT = DEPARTMENT.DEPTNO<br />         AND EDLEVEL > (SELECT AVG(EDLEVEL)<br />                           FROM EMPLOYEE E2<br />                           WHERE E2.WORKDEPT = E1.WORKDEPT)</p> <p>This statement produces the following result: </p> <p> LASTNAME        DEPTNAME                      EDLEVEL<br />  --------------- ----------------------------- -------<br />  HAAS            SPIFFY COMPUTER SERVICE DIV.       18<br />  LUCCHESSI       SPIFFY COMPUTER SERVICE DIV.       19<br />  KWAN            INFORMATION CENTER                 20<br />  PIANKA          MANUFACTURING SYSTEMS              17<br />  SCOUTTEN        MANUFACTURING SYSTEMS              17<br />  JONES           MANUFACTURING SYSTEMS              17<br />  LUTZ            MANUFACTURING SYSTEMS              18<br />  PULASKI         ADMINISTRATION SYSTEMS             16<br />  MARINO          ADMINISTRATION SYSTEMS             17<br />  JOHNSON         ADMINISTRATION SYSTEMS             16<br />  HENDERSON       OPERATIONS                         16<br />  SCHNEIDER       OPERATIONS                         17<br />  MEHTA           SOFTWARE SUPPORT                   16<br />  GOUNOT          SOFTWARE SUPPORT                   16</p> <p>The above examples show that the correlation name used in a subquery must be defined in the FROM clause of some query that contains the correlated subquery. However, this containment may involve several levels of nesting. </p> <p>Suppose that some departments have only a few employees and therefore their average education level may be misleading. You might decide that in order for the average level of education to be a meaningful number to compare an employee against, there must be at least five employees in a department. So now we have to list the employees whose level of education is higher than the average for that employee's department, and only consider departments with at least five employees. </p> <p>The problem implies another subquery because, for each employee in the outer-level query, the total number of employees in that person's department must be counted: </p> <p>     SELECT COUNT(*)<br />         FROM EMPLOYEE E3<br />         WHERE E3.WORKDEPT = E1.WORKDEPT</p> <p>Only if the count is greater than or equal to 5 is an average to be computed: </p> <p>     SELECT AVG(EDLEVEL)<br />         FROM EMPLOYEE E2<br />         WHERE E2.WORKDEPT = E1.WORKDEPT<br />         AND 5 <= (SELECT COUNT(*)<br />                      FROM EMPLOYEE  E3<br />                      WHERE E3.WORKDEPT = E1.WORKDEPT)</p> <p>Finally, only those employees whose level of education is greater than the average for that department are included: </p> <p>     SELECT LASTNAME, DEPTNAME, EDLEVEL<br />         FROM EMPLOYEE E1, DEPARTMENT<br />         WHERE E1.WORKDEPT = DEPARTMENT.DEPTNO<br />         AND EDLEVEL > <br />         (SELECT AVG(EDLEVEL)<br />             FROM EMPLOYEE E2<br />             WHERE E2.WORKDEPT = E1.WORKDEPT<br />             AND 5 <=<br />             (SELECT COUNT(*)<br />                 FROM EMPLOYEE E3<br />                 WHERE E3.WORKDEPT = E1.WORKDEPT))</p> <p>This statement produces the following result: </p> <p>     LASTNAME        DEPTNAME                      EDLEVEL<br />      --------------- ----------------------------- -------<br />      PIANKA          MANUFACTURING SYSTEMS              17<br />      SCOUTTEN        MANUFACTURING SYSTEMS              17<br />      JONES           MANUFACTURING SYSTEMS              17<br />      LUTZ            MANUFACTURING SYSTEMS              18<br />      PULASKI         ADMINISTRATION SYSTEMS             16<br />      MARINO          ADMINISTRATION SYSTEMS             17<br />      JOHNSON         ADMINISTRATION SYSTEMS             16<br />      HENDERSON       OPERATIONS                         16<br />      SCHNEIDER       OPERATIONS                         17</p> <br /> 娉細<br /> 1.浠涔堟椂鍊欑敤鐩稿叧瀛愭煡璇㈠憿錛?br /> 褰撴煡璇㈡潯浠朵腑鍖呭惈鏈夊column鐨勫嚱鏁拌綆楁椂錛岃冭檻浣跨敤鐩稿叧瀛愭煡璇紱<br /> 2.鍦℉ibernate閲屽浣曞疄鐜扮浉鍏沖瓙鏌ヨ鐨勫姛鑳藉憿錛?br /> <br /> <img src ="http://www.aygfsteel.com/koradji/aggbug/301690.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/koradji/" target="_blank">koradji</a> 2009-11-09 14:04 <a href="http://www.aygfsteel.com/koradji/articles/301690.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>db2 PATCH鐢ㄦ硶http://www.aygfsteel.com/koradji/articles/257837.htmlkoradjikoradjiWed, 04 Mar 2009 09:27:00 GMThttp://www.aygfsteel.com/koradji/articles/257837.htmlhttp://www.aygfsteel.com/koradji/comments/257837.htmlhttp://www.aygfsteel.com/koradji/articles/257837.html#Feedback0http://www.aygfsteel.com/koradji/comments/commentRss/257837.htmlhttp://www.aygfsteel.com/koradji/services/trackbacks/257837.html 鍏蜂綋鐨勬柟娉曟槸錛屽湪澶ф満鐜涓嬶紝緙栧啓shell鑴氭湰鏉ユ墽琛宒b2鍛戒護銆?br /> 涓句緥錛?br />

#! /usr/bin/ksh
#
#
#
db2 connect to 琛ㄥ悕 user <userid>  using <password>
db2 set current schema <schema鍚?gt;
#瀵煎嚭琛ㄤ腑鏁版嵁錛屽浠芥璇佺敤
db2 "export to T37A00MG_01BEFORE.csv of del messages export.log select * from T37A00MG"
db2 "export to T37A00SF_01BEFORE.csv of del messages export.log select * from T37A00SF"
#鏌ヨ
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00MG group by KA4ZN,TE0WA"
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00SF group by KA4ZN,TE0WA"
#鏇存柊鏁版嵁
db2 "update T37A00MG set TE0WA='SYSTEM' where TE0WA<> 'SYSTEM'"
db2 "update T37A00SF set TE0WA='SYSTEM' where TE0WA<> 'SYSTEM'"
#鏌ヨ紜
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00MG group by KA4ZN,TE0WA"
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00SF group by KA4ZN,TE0WA"
#瀵煎嚭琛ㄤ腑鏁版嵁錛屽浠芥璇佺敤
db2 "export to T37A00MG_02AFTER.csv of del messages export.log select * from T37A00MG"
db2 "export to T37A00SF_02AFTER.csv of del messages export.log select * from T37A00SF"



koradji 2009-03-04 17:27 鍙戣〃璇勮
]]>
db2甯哥敤鍛戒護http://www.aygfsteel.com/koradji/articles/257831.htmlkoradjikoradjiWed, 04 Mar 2009 09:06:00 GMThttp://www.aygfsteel.com/koradji/articles/257831.htmlhttp://www.aygfsteel.com/koradji/comments/257831.htmlhttp://www.aygfsteel.com/koradji/articles/257831.html#Feedback0http://www.aygfsteel.com/koradji/comments/commentRss/257831.htmlhttp://www.aygfsteel.com/koradji/services/trackbacks/257831.htmlIBM DB2涓婃満鎿嶄綔鎸囧崡
1.鍚姩瀹炰緥(db2inst1)錛氬疄渚嬬浉褰撲簬informix涓殑鏈嶅姟
db2start
2.鍋滄瀹炰緥(db2inst1)錛?br /> db2stop
3.鍒楀嚭鎵鏈夊疄渚?db2inst1)
db2ilist
4.鍒楀嚭褰撳墠瀹炰緥錛?br /> db2 get instance
5.瀵熺湅紺轟緥閰嶇疆鏂囦歡錛?br /> db2 get dbm cfg|more
6.鏇存柊鏁版嵁搴撶鐞嗗櫒鍙傛暟淇℃伅錛?br /> db2 update dbm cfg using para_name para_value
7.鍒涘緩鏁版嵁搴擄細
db2 create db test
8.瀵熺湅鏁版嵁搴撻厤緗弬鏁頒俊鎭?br /> db2 get db cfg for test|more
9.鏇存柊鏁版嵁搴撳弬鏁伴厤緗俊鎭?br /> db2 update db cfg for test using para_name para_value
10.鍒犻櫎鏁版嵁搴擄細
db2 drop db test
11.榪炴帴鏁版嵁搴?br /> db2 connect to test
12.鍒楀嚭鎵鏈夎〃絀洪棿鐨勮緇嗕俊鎭?br /> db2 list tablespaces show detail
13.鍒楀嚭瀹瑰櫒鐨勪俊鎭?br /> db2 list tablespace containers for tbs_id show detail
13.鍒涘緩琛細
db2 ceate table tb1(id integer not null,name char(10))
14.鍒楀嚭鎵鏈夎〃
db2 list tables
15.鎻掑叆鏁版嵁錛?br /> db2 insert into tb1 values(1,’sam’);
db2 insert into tb2 values(2,’smitty’);
16.鏌ヨ鏁版嵁錛?br /> db2 “select * from tb1”
17.鍒犻櫎鏁版嵁錛?br /> db2 delete from tb1 where id=1
18.鍒涘緩绱㈠紩錛?br /> db2 create index idx1 on tb1(id);
19.鍒涘緩瑙嗗浘錛?br /> db2 create view view1 as select id from tb1
20.鏌ヨ瑙嗗浘錛?br /> db2 select * from view1
21.鑺傜偣緙栫洰
db2 catalog tcp node node_name remote server_ip server server_port
22.瀵熺湅绔彛鍙?br /> db2 get dbm cfg|grep SVCENAME
23.鑺傜偣鐨勯檮鎺?br /> db2 attach to node_name
24.瀵熺湅鏈湴鑺傜偣
db2 list node direcotry
25.鑺傜偣鍙嶇紪鐩?br /> db2 uncatalog node node_name
26.鏁版嵁搴撶紪鐩?br /> db2 catalog db db_name as db_alias at node node_name
27.瀵熺湅鏁版嵁搴撶殑緙栫洰
db2 list db directory
28.榪炴帴鏁版嵁搴?br /> db2 connect to db_alias user user_name using user_password
29.鏁版嵁搴撳弽緙栫洰
db2 uncatalog db db_alias
30.瀵煎嚭鏁版嵁
db2 export to myfile of ixf messages msg select * from tb1
31.瀵煎叆鏁版嵁
db2 import from myfile of ixf messages msg replace into tb1
32.瀵煎嚭鏁版嵁搴撶殑鎵鏈夎〃鏁版嵁
db2move test export
33.鐢熸垚鏁版嵁搴撶殑瀹氫箟
db2look -d db_alias -a -e -m -l -x -f -o db2look.sql
34.鍒涘緩鏁版嵁搴?br /> db2 create db test1
35.鐢熸垚瀹氫箟
db2 -tvf db2look.sql
36.瀵煎叆鏁版嵁搴撴墍鏈夌殑鏁版嵁
db2move db_alias import
37.閲嶇粍媯鏌?br /> db2 reorgchk
38.閲嶇粍琛╰b1
db2 reorg table tb1
39.鏇存柊緇熻淇℃伅
db2 runstats on table tb1
40.澶囦喚鏁版嵁搴搕est
db2 backup db test
41.鎭㈠鏁版嵁搴搕est
db2 restore db test
42. 鎷ユ湁瀹炰緥鐨勬墍鏈夌▼搴忓垪琛?br /> db2 list application
43.
db2 terminate
44.鏌ョ湅鏁版嵁琛ㄧ粨鏋?br /> db2 “describe select * from ggwdxtcs”

/*鍚姩鍛戒護鐣岄潰 */    db2cmd
/*鏌ョ湅甯姪*/  db2 ? *
/*榪炴帴鏁版嵁搴?/   db2 connect to  user  using
/*鏌ョ湅鏁版嵁搴撳疄渚?/ db2ilist
/*鍚姩鏁版嵁搴?/  db2start
/*鍋滄鏁版嵁搴撳簲鐢?/ db2 force applications all
/*鍋滄暟鎹簱*/  db2stop
/*鏌ョ湅琛ㄧ┖闂?  db2 list tablespaces show detail
/*鏌ョ湅琛ㄦ槸鍚︽湁璁板綍*/ db2 select count(*) from
/*浠庢枃鏈鍏ュ埌鏁版嵁搴撹〃涓?/ db2 import from ***.ixf of ixf modified by forcein commitcount 1000 insert into
   
modified by forcein  /*鏁版嵁搴撴暟鎹湪AIX 鍜?windows 涓嶅悓鐗堟湰涔嬮棿鐨勬牸寮忚漿鎹?/
      
commitcount **** /*闃叉鏁版嵁搴撴彁浜よ繃澶氾紝寮曡搗浜ゆ槗鏃ュ織婊?1000錛?000 涓哄疁*/
渚嬪瓙錛歞b2 "import from c:\zj\321104\bbsybsj.ixf of ixf modified by forcein insert into bbsybsj"
/*鏌ョ湅sql璇彞閿欒瑙i噴*/ db2 ? sql**** ****涓哄洓浣嶅嚭閿欑紪鐮侊紝涓嶈凍浣嶅墠琛?

db2 ? “sqlstate”
db2 ? sqlstate=42884
db2 “select * from syscat.functions” |grep –i rtrim
db2 “select * from syscat.indexes”
琛ㄥ鍔犲垪
db2 alter table 琛ㄥ悕 add column 瀛楁鍚?varchar(4)(瀛楁綾誨瀷錛?br /> 淇敼琛ㄩ噷鐨勫瓧孌?br /> db2 update 琛ㄥ悕 set 瀛楁鍚?'xxx' where .....

koradji 2009-03-04 17:06 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 正阳县| 漳州市| 泗洪县| 常州市| 嵩明县| 永丰县| 花垣县| 吉水县| 东明县| 准格尔旗| 抚顺市| 普陀区| 子洲县| 麻江县| 武功县| 南安市| 富民县| 莆田市| 会理县| 宁化县| 会同县| 临夏县| 任丘市| 万州区| 天柱县| 历史| 东宁县| 宜阳县| 绵竹市| 习水县| 德阳市| 新河县| 淳安县| 镶黄旗| 肥西县| 岢岚县| 玉屏| 临泽县| 阳西县| 海阳市| 大港区|