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

OracleÖÐconnect by...start with...µÄʹÓÃ

Ò»¡¢Óï·¨
´óÖÂд·¨£ºselect * from some_table [where Ìõ¼þ1] connect by [Ìõ¼þ2] start with [Ìõ¼þ3];
ÆäÖÐ connect by Óë start with Óï¾ä°Ú·ÅµÄÏȺó˳Ðò²»Ó°Ïì²éѯµÄ½á¹û£¬[where Ìõ¼þ1]¿ÉÒÔ²»ÐèÒª¡£
[where Ìõ¼þ1]¡¢[Ìõ¼þ2]¡¢[Ìõ¼þ3]¸÷×Ô×÷Óõķ¶Î§¶¼²»Ïàͬ£º
[where Ìõ¼þ1]ÊÇÔÚ¸ù¾Ý“connect by [Ìõ¼þ2] start with [Ìõ¼þ3]”Ñ¡Ôñ³öÀ´µÄ¼Ç¼ÖнøÐйýÂË£¬ÊÇÕë¶Ôµ¥Ìõ¼Ç¼µÄ¹ýÂË£¬ ²»»á¿¼ÂÇÊ÷µÄ½á¹¹£»
[Ìõ¼þ2]Ö¸¶¨¹¹ÔìÊ÷µÄÌõ¼þ£¬ÒÔ¼°¶ÔÊ÷·ÖÖ§µÄ¹ýÂËÌõ¼þ£¬ÔÚÕâÀïÖ´ÐеĹýÂË»á°Ñ·ûºÏÌõ¼þµÄ¼Ç¼¼°ÆäϵÄËùÓÐ×ӽڵ㶼¹ýÂ˵ô£»
[Ìõ¼þ3]ÏÞ¶¨×÷ΪËÑË÷ÆðʼµãµÄÌõ¼þ£¬Èç¹ûÊÇ×ÔÉ϶øϵÄËÑË÷ÔòÊÇÏÞ¶¨×÷Ϊ¸ù½ÚµãµÄÌõ¼þ£¬Èç¹ûÊÇ×Ô϶øÉϵÄËÑË÷ÔòÊÇÏÞ¶¨×÷ΪҶ×Ó½ÚµãµÄÌõ¼þ£»
ʾÀý£º
¼ÙÈçÓÐÈçϽṹµÄ±í£ºsome_table(id,p_id,name)£¬ÆäÖÐp_id±£´æ¸¸¼Ç¼µÄid¡£
select * from some_table t where t.id!=123 connect by prior t.p_id=t.id and t.p_id!=321 start with t.p_id=33 or t.p_id=66;
¶ÔpriorµÄ˵Ã÷£º
    prior´æÔÚÓÚ[Ìõ¼þ2]ÖУ¬¿ÉÒÔ²»Òª£¬²»ÒªµÄʱºòÖ»ÄܲéÕÒµ½·ûºÏ“start with [Ìõ¼þ3]”µÄ¼Ç¼£¬²»»áÔÚÑ°ÕÒÕâЩ¼Ç¼µÄ×ӽڵ㡣ҪµÄʱºòÓÐÁ½ÖÖд·¨£ºconnect by prior t.p_id=t.id »ò connect by t.p_id=prior t.id£¬Ç°Ò»ÖÖд·¨±íʾ²ÉÓÃ×ÔÉ϶øϵÄËÑË÷·½Ê½£¨ÏÈÕÒ¸¸½ÚµãÈ»ºóÕÒ×ӽڵ㣩£¬ºóÒ»ÖÖд·¨±íʾ²ÉÓÃ×Ô϶øÉϵÄËÑË÷·½Ê½£¨ÏÈÕÒÒ¶×Ó½ÚµãÈ»ºóÕÒ¸¸½Úµã£©¡£
¶þ¡¢Ö´ÐÐÔ­Àí
connect by...start with...µÄÖ´ÐÐÔ­Àí¿ÉÒÔÓÃÒÔÏÂÒ»¶Î³ÌÐòµÄÖ´ÐÐÒÔ¼°¶Ô´æ´¢¹ý³ÌRECURSE()µÄµ÷ÓÃÀ´ËµÃ÷£º
/* ±éÀú±íÖеÄÿÌõ¼Ç¼£¬¶Ô±ÈÊÇ·ñÂú×ãstart withºóµÄÌõ¼þ£¬Èç¹û²»Âú×ãÔò¼ÌÐøÏÂÒ»Ìõ£¬
Èç¹ûÂú×ãÔòÒԸüÇ¼Ϊ¸ù½Úµã£¬È»ºóµ÷ÓÃRECURSE()µÝ¹éÑ°ÕҸýڵãϵÄ×ӽڵ㣬
Èç´ËÑ­»·Ö±µ½±éÀúÍêÕû¸ö±íµÄËùÓмǼ ¡£*/
for rec in (select * from some_table) loop
if FULLFILLS_START_WITH_CONDITION(rec) then
    RECURSE(rec, rec.child);
end if;
end loop;
/* Ñ°ÕÒ×Ó½ÚµãµÄ´æ´¢¹ý³Ì*/
procedure RECURSE (rec in MATCHES_SELECT_STMT, new_parent IN field_type) is
begin
APPEND_RESULT_LIST(rec); /*°Ñ¼Ç¼¼ÓÈë½á¹û¼¯ºÏÖÐ*/
/*ÔٴαéÀú±íÖеÄËùÓмǼ£¬¶Ô±ÈÊÇ·ñÂú×ãconnect byºóµÄÌõ¼þ£¬Èç¹û²»Âú×ãÔò¼ÌÐøÏÂÒ»Ìõ£¬
Èç¹ûÂú×ãÔòÔÙÒԸüÇ¼Ϊ¸ù½Úµã£¬È»ºóµ÷ÓÃRECURSE()¼ÌÐøµÝ¹é


Ïà¹ØÎĵµ£º

¹ØÓÚplsqlÖеÄdefine±äÁ¿ÒÔ¼°Oracle±äÁ¿·ÖÀàС½á

¹ØÓÚplsqlÖеÄdefine±äÁ¿ÒÔ¼°Oracle±äÁ¿·ÖÀàС½á
2009-07-29 15:18
ÏȼÇÔظÕÀ§ÈÅÎÒµÄÒ»¸öÎÊÌ⣬×î½üѧϰplsql£¬ÓÉÓÚËùÓÃѧϰÊé¼®ºóÃæÌṩÌâÄ¿³£Óõ½define±äÁ¿£¬µ«ÓÉÓÚÕâÒ»±äÁ¿µÄʹÓÃÌØÊâÐÔ£¬×Ô¼º±ãѰ˼ÕâÒ»±äÁ¿ËùÊéÀà±ð£¬OracleÌṩµÄ±äÁ¿·ÖÀ๲ÓÐËÄÀࣺ
1£©±êÁ¿£¨scalar£©ÀàÐÍ
2£©¸´ºÏ£¨composite£©ÀàÐÍ
3£©²ÎÕÕ£¨re ......

±±´óÇàÄñoracleѧϰ±Ê¼Ç26 27 28

Êý¾Ý¿â´¥·¢Æ÷
´¥·¢Æ÷Óï¾ä
    Öƶ¨´¥·¢Æ÷¶¨Ê±¡¢Ê¼þ¡¢±íÃû¼°ÀàÐÍ
´¥·¢Æ÷Ö÷Ìå
    ÊÇpl/sql¿ì»ò¶Ô¹ý³ÌµÄµ÷ÓÃ
´¥·¢Æ÷ÏÞÖÆ
    ¿ÉÒÔͨ¹ýwhen×Ó¾äʵÏÖ
DML(insert update delete)
DDL(create alter drop)
Êý¾Ý¿â²Ù×÷(servererror logo ......

.NetÓëOracleµÄÊý¾Ý¿âÁ¬½Ó³Ø


ʱ¼ä: 2006-06-15  À´×Ô£ºCSDN
< type="text/javascript"><!--
google_ad_client = "pub-0103898066674568";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel = "";
google_color_ ......

Install Oracle 10g on SuSE 10

Õâ´ÎµÄ¾­ÀúÊÇ×Ô¼ºÕÒÀ´µÄ£¬ÔÚ°²×°ÁË10gµÄÄÇ̨»úÉÏÉý¼¶ÏÂÄÚ´æÒ²±ãÄܺöÓÆÄÇȺÓÑ£¬²»¹ýÏëÏ뻹ÊÇÕÛÌÚÏ°ɣ¬¸øÒƵ½ÅäÖúõãµÄServerÉÏÃ棬ËûÃÇÓÃÆðÀ´Ë³ÐÄ£¬ÎÒ×Ô¼ºÒ²ÄÜÕÛÌڵ㾭Ñé¡£
132µÄϵͳÊÇSuSE10.2µÄ£¬Ö®Ç°ÒѾ­°²×°ÁËOracle 9i£¬Õâ¾ÍÒâζ×űØÐëÏÈжÔصô9i£¬±¾ÒÔΪ°²×°10gµÄrunInstallerÄܹ»Ð¶Ôصô9i£¬¿É³¢ÊÔÁ˺þö¼ÊdzöÏÖex ......

ÈçºÎÔÚoracleÖе¼Èëµ¼³ödmpÊý¾Ý¿âÎļþ

OracleÊý¾Ýµ¼Èëµ¼³öimp/exp¾ÍÏ൱ÓÚoracleÊý¾Ý»¹Ô­Ó뱸·Ý¡£expÃüÁî¿ÉÒÔ°ÑÊý¾Ý´ÓÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷µ¼³öµ½±¾µØµÄdmpÎļþ£¬impÃüÁî¿ÉÒÔ°ÑdmpÎļþ´Ó±¾µØµ¼Èëµ½Ô¶´¦µÄÊý¾Ý¿â·þÎñÆ÷ÖС£ ÀûÓÃÕâ¸ö¹¦ÄÜ¿ÉÒÔ¹¹½¨Á½¸öÏàͬµÄÊý¾Ý¿â£¬Ò»¸öÓÃÀ´²âÊÔ£¬Ò»¸öÓÃÀ´ÕýʽʹÓá£
 
Ö´Ðл·¾³£º¿ÉÒÔÔÚSQLPLUS.EXE»òÕßDOS£¨ÃüÁîÐУ©ÖÐÖ´Ð ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ