Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¡¾×ª¡¿ Oracle group by¼°ÆäÈô¸ÉÏà¹Øº¯ÊýµÄһЩ˵Ã÷

Oracle group by¼°ÆäÈô¸ÉÏà¹Øº¯ÊýµÄһЩ˵Ã÷
http://blog.csdn.net/roland_wg/archive/2009/07/03/4319323.aspx
OracleµÄgroup by³ýÁË»ù±¾Ó÷¨ÒÔÍ⣬»¹ÓÐ3ÖÖÀ©Õ¹Ó÷¨£¬·Ö±ðÊÇrollup¡¢cube¡¢grouping sets¡£
¼ÙÉèÓÐÒ»¸ö±ítest£¬ÓÐA¡¢B¡¢C¡¢D¡¢E5ÁС£
1£© Èç¹ûʹÓÃgroup by rollup(A,B,C)£¬Ê×ÏÈ»á¶Ô(A¡¢B¡¢C)½øÐÐGROUP BY£¬È»ºó¶Ô(A¡¢B)½øÐÐGROUP BY£¬È»ºóÊÇ(A)½øÐÐGROUP BY£¬×îºó¶ÔÈ«±í½øÐÐGROUP BY²Ù×÷¡£roll upµÄÒâ˼ÊÇ“¾íÆ𔣬ÕâÒ²¿ÉÒÔ°ïÖúÎÒÃÇÀí½âgroup by rollup¾ÍÊǶÔÑ¡ÔñµÄÁдÓÓÒµ½×óÒÔÒ»´ÎÉÙÒ»Áеķ½Ê½½øÐÐgroupingÖ±µ½ËùÓÐÁж¼È¥µôºóµÄgrouping(Ò²¾ÍÊÇÈ«±ígrouping)£¬¶ÔÓÚn¸ö²ÎÊýµÄrollup£¬ÓÐn+1´ÎµÄgrouping¡£ÒÔÏÂ2¸ösqlµÄ½á¹û¼¯ÊÇÒ»ÑùµÄ£º
Select A,B,C,sum(E) from test group by rollup(A,B,C)ºÍ
Select A,B,C,sum(E) from test group by A,B,C
union all
Select A,B,null,sum(E) from test group by A,B
union all
Select A,null,null,sum(E) from test group by A
union all
Select null,null,null,sum(E) from test
2) cubeµÄÒâ˼ÊÇÁ¢·½£¬¶ÔcubeµÄÿ¸ö²ÎÊý£¬¶¼¿ÉÒÔÀí½âΪȡֵΪ²ÎÓëgroupingºÍ²»²ÎÓëgroupingÁ½¸öÖµµÄÒ»¸öά¶È£¬È»ºóËùÓÐά¶ÈÈ¡Öµ×éºÏµÄ¼¯ºÏ¾ÍÊÇgroupingµÄ¼¯ºÏ£¬¶ÔÓÚn¸ö²ÎÊýµÄcube£¬ÓÐ2^n´ÎµÄgrouping¡£Èç¹ûʹÓÃgroup by cube(A,B,C), £¬ÔòÊ×ÏÈ»á¶Ô(A¡¢B¡¢C)½øÐÐGROUP BY£¬È»ºóÒÀ´ÎÊÇ(A¡¢B)£¬(A¡¢C)£¬(A)£¬(B¡¢C)£¬(B)£¬(C)£¬×îºó¶ÔÈ«±í½øÐÐGROUP BY²Ù×÷£¬Ò»¹²ÊÇ2^3=8´Îgrouping¡£Í¬rollupÒ»Ñù£¬Ò²¿ÉÒÔÓûù±¾µÄgroup by¼ÓÉϽá¹û¼¯µÄunion allд³öÒ»¸öÓëgroup by cube½á¹û¼¯ÏàͬµÄsql£º
Select A,B,C,sum(E) from test group by cube(A,B,C)£»
Select A,B,C,sum(E) from test group by A,B,C
union all
Select A,B,null,sum(E) from test group by A,B
union all
Select A,null,C,sum(E) from test group by A,C
union all
Select A,null,null,sum(E) from test group by A
union all
Select null,B,C,sum(E) from test group by B,C
union all
Select null,B,null,sum(E) from test group by B
union all
Select null,null,C,sum(E) from test group by C
union all
Select null,null,null,sum(E) from test
3) grouping sets¾ÍÊǶԲÎÊýÖеÄÿ¸ö²ÎÊý×ögrouping£¬Ò²¾ÍÊÇÓм¸¸ö²ÎÊý×ö¼¸´Îgrouping, ÀýÈçʹÓÃgroup by grouping sets(A,B,C)£¬Ôò¶Ô(A),(B),(C)½øÐÐgroup by£¬È


Ïà¹ØÎĵµ£º

¹ØÓÚOracleÖÐtnsnames.oraµÄÅäÖÃ


ÿ´Îͨ¹ýÐÞ¸Ätnsnames.oraÅäÖñ¾µØNET·þÎñÃû¶¼³öÏÖ´íÎó“ORA-12154:TNS£¬ÎÞ·¨´¦Àí·þÎñÃû”£¬×ܵÃÓôÃÆ°ëÌì~
Õâ¸ö´íÎó£¬Í¨³£ÊÇÒòΪoracle±¾µØNET·þÎñÃûÅäÖÃtnsnames.oraÎļþÓÐÑϸñµÄ¸ñʽҪÇó¡£
ÀýÈ磺
mstrdw =
  (DESCRIPTION =
    (ADDRESS_LIST =
      ......

ORACLE JOB ÉèÖÃ

                   
    JobµÄ²ÎÊý£º
    Ò»£ºÊ±¼ä¼ä¸ôÖ´ÐУ¨Ã¿·ÖÖÓ£¬Ã¿Ì죬ÿÖÜ£¬:ÿÔ£¬Ã¿¼¾¶È£¬Ã¿°ëÄ꣬ÿÄ꣩
   intervalÊÇÖ¸ÉÏÒ»´ÎÖ´ÐнáÊøµ½ÏÂÒ»´Î¿ªÊ¼Ö´ÐеÄʱ¼ä¼ ......

oracleÖÐtypeµÄʹÓÃ

create or replace type mytype IS TABLE OF varchar2(20);
declare type1 mytype :=mytype('1','2','3','4');
i number:=1;
var_str varchar(20):='liaomin';
begin
type1.EXTEND;
type1(type1.COUNT):=var_str;
loop
  dbms_output.put_line(type1(i));
  i:=i+1;
  exit when i=type1.count+1; ......

PERL ÒýÆðOracleÊý¾Ý¿â100% CPU

½ñÌìÓöµ½Ò»¸öÎÊÌ⣬PERL ÒýÆðOracleÊý¾Ý¿â100% CPU£¬ÏµÍ³ÊÇenterprise linux 4 update 7 64 bit
²é¿´½ø³ÌÔ­À´ÊÇgridµÄagent¡£Ö»ÓÐÏÈÍ£µôgrid
./emctl stop agent
./opmn stopall
pkill -9 perl
È»ºóÔÙ¿´¿´ÓÐûÓÐʲôbug¡£ ÕâÊǸöbug£¬ ´òÁËpatch 5908032ºóºÃÏñÕý³£ÁË¡£
oracle     549 &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ