OracleÖÐstart with...connect by prior×Ó¾äÓ÷¨
connect by Êǽṹ»¯²éѯÖÐÓõ½µÄ£¬Æä»ù±¾Óï·¨ÊÇ£º
select ... from tablename start with Ìõ¼þ1
connect by Ìõ¼þ2
where Ìõ¼þ3;
Àý£º
select * from table
start with org_id = 'HBHqfWGWPy'
connect by prior org_id = parent_id;
¼òµ¥ËµÀ´Êǽ«Ò»¸öÊ÷×´½á¹¹´æ´¢ÔÚÒ»ÕűíÀ±ÈÈçÒ»¸ö±íÖдæÔÚÁ½¸ö×Ö¶Î:
org_id,parent_idÄÇôͨ¹ý±íʾÿһÌõ¼Ç¼µÄparentÊÇË£¬¾Í¿ÉÒÔÐγÉÒ»¸öÊ÷×´½á¹¹¡£
ÓÃÉÏÊöÓï·¨µÄ²éѯ¿ÉÒÔÈ¡µÃÕâ¿ÃÊ÷µÄËùÓмǼ¡£
ÆäÖУº
Ìõ¼þ1 ÊǸù½áµãµÄÏÞ¶¨Óï¾ä£¬µ±È»¿ÉÒÔ·Å¿íÏÞ¶¨Ìõ¼þ£¬ÒÔÈ¡µÃ¶à¸ö¸ù½áµã£¬Êµ¼Ê¾ÍÊǶà¿ÃÊ÷¡£
Ìõ¼þ2 ÊÇÁ¬½ÓÌõ¼þ£¬ÆäÖÐÓÃPRIOR±íʾÉÏÒ»Ìõ¼Ç¼£¬±ÈÈç CONNECT BY PRIOR org_id = parent_id¾ÍÊÇ˵ÉÏÒ»Ìõ¼Ç¼µÄorg_id ÊDZ¾Ìõ¼Ç¼µÄparent_id£¬¼´±¾¼Ç¼µÄ¸¸Ç×ÊÇÉÏÒ»Ìõ¼Ç¼¡£
Ìõ¼þ3 ÊǹýÂËÌõ¼þ£¬ÓÃÓÚ¶Ô·µ»ØµÄËùÓмǼ½øÐйýÂË¡£
¼òµ¥½éÉÜÈçÏ£º
ÔçɨÃèÊ÷½á¹¹±íʱ£¬ÐèÒªÒÀ´Ë·ÃÎÊÊ÷½á¹¹µÄÿ¸ö½Úµã£¬Ò»¸ö½ÚµãÖ»ÄÜ·ÃÎÊÒ»´Î£¬Æä·ÃÎʵIJ½ÖèÈçÏ£º
µÚÒ»²½£º´Ó¸ù½Úµã¿ªÊ¼£»
µÚ¶þ²½£º·ÃÎʸýڵ㣻
µÚÈý²½£ºÅжϸýڵãÓÐÎÞδ±»·ÃÎʵÄ×ӽڵ㣬ÈôÓУ¬ÔòתÏòËü×î×ó²àµÄδ±»·ÃÎʵÄ×Ó½Ú£¬²¢Ö´Ðеڶþ²½£¬·ñÔòÖ´ÐеÚËIJ½£»
µÚËIJ½£ºÈô¸Ã½ÚµãΪ¸ù½Úµã£¬Ôò·ÃÎÊÍê±Ï£¬·ñÔòÖ´ÐеÚÎå²½£»
µÚÎå²½£º·µ»Øµ½¸Ã½ÚµãµÄ¸¸½Úµã£¬²¢Ö´ÐеÚÈý²½Öè¡£
×ÜÖ®£ºÉ¨ÃèÕû¸öÊ÷½á¹¹µÄ¹ý³ÌÒ²¼´ÊÇÖÐÐò±éÀúÊ÷µÄ¹ý³Ì¡£
1£® Ê÷½á¹¹µÄÃèÊö
Ê÷½á¹¹µÄÊý¾Ý´æ·ÅÔÚ±íÖУ¬Êý¾ÝÖ®¼äµÄ²ã´Î¹Øϵ¼´¸¸×Ó¹Øϵ£¬Í¨¹ý±íÖеÄÁÐÓëÁмäµÄ¹ØϵÀ´ÃèÊö£¬ÈçEMP±íÖеÄEMPNOºÍMGR¡£EMPNO±íʾ¸Ã¹ÍÔ±µÄ±àºÅ£¬MGR±íʾÁìµ¼¸Ã¹ÍÔ±µÄÈ˵ıàºÅ£¬¼´×Ó½ÚµãµÄMGRÖµµÈÓÚ¸¸½ÚµãµÄEMPNOÖµ¡£ÔÚ±íµÄÿһÐÐÖж¼ÓÐÒ»¸ö±íʾ¸¸½ÚµãµÄMGR£¨³ý¸ù½ÚµãÍ⣩£¬Í¨¹ýÿ¸ö½ÚµãµÄ¸¸½Úµã£¬¾Í¿ÉÒÔÈ·¶¨Õû¸öÊ÷½á¹¹¡£
ÔÚSELECTÃüÁîÖÐʹÓÃCONNECT BY ºÍ°ªSTART WITH ×Ó¾ä¿ÉÒÔ²éѯ±íÖеÄÊ÷Ðͽṹ¹Øϵ¡£ÆäÃüÁî¸ñʽÈçÏ£º
SELECT ¡£¡£¡£
CONNECT BY {PRIOR ÁÐÃû1=ÁÐÃû2|ÁÐÃû1=PRIOR ÁÑÃû2}
[START WITH]£»
ÆäÖУºCONNECT BY×Ó¾ä˵Ã÷ÿÐÐÊý¾Ý½«ÊÇ°´²ã´Î˳Ðò¼ìË÷£¬²¢¹æ¶¨½«±íÖеÄÊý¾ÝÁ¬ÈëÊ÷ÐͽṹµÄ¹ØϵÖС£PRIORYÔËËã·û±ØÐë·ÅÖÃÔÚÁ¬½Ó¹ØϵµÄÁ½ÁÐÖÐijһ¸öµÄÇ°Ãæ¡£¶ÔÓÚ½Úµã¼äµÄ¸¸×Ó¹Øϵ£¬PRIORÔËËã·ûÔÚÒ»²à±íʾ¸¸½Úµã£¬ÔÚÁíÒ»²à±íʾ×ӽڵ㣬´Ó¶øÈ·¶¨²éÕÒÊ÷½á¹¹ÊǵÄ˳ÐòÊÇ×Ô¶¥ÏòÏ»¹ÊÇ×Ôµ×ÏòÉÏ¡£ÔÚÁ¬½Ó¹ØϵÖУ¬³ýÁË¿ÉÒÔʹÓÃÁÐÃûÍ⣬»¹ÔÊÐíʹÓÃÁбí´ïʽ¡£START WITH ×Ó¾äΪ¿ÉÑ¡ÏÓÃÀ´±
Ïà¹ØÎĵµ£º
±ítask£¬×Ö¶Îid_£¬name_
id_µÄÊý¾ÝÈçÏÂÐÎʽ£º
1
1.1
1.1.1
1.1.1.2
1.2
1.2.1
...
10
10.1
10.1.1
10.2.1
10.2.1.1
10.2.1.1.1
10.2.1.1.2
.......
×¢£º“.”±êʶ¸¸×ӵĹØϵ¡£
ÏÖÔÚͨ¹ýid_²éѯÊ÷½á¹¹µÄЧ¹û£¬²¢ÇÒÖªµÀ´Ë½ÚµãÊÇ·ñΪҶ×Ó½Úµãleaf¡£¡££¿
Óï¾äÈçÏ£º
select
......
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_crypto.htm
oracle×Ô´øÎĵµÐ´µÄ±È½ÏÇå³þ
24
DBMS_CRYPTO
DBMS_CRYPTO
provides an interface to encrypt and
decrypt stored data, and can be used in conjunction with PL/SQL
programs running network communications. It provides suppo ......
1.ÓÃOracleÓû§µÇ½Linux·þÎñÆ÷;
2.ÔÚÖն˴°¿ÚÊäÈë sqlplus /nolog
[oracle@hylinux ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on ÐÇÆÚ¶þ 7ÔÂ 29 14:26:16 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
& ......
1. ×¼±¸¹¤×÷
°Ñ¾ÉµÄORACLEËùÓÐÎļþ¶¼COPY±¸·ÝÏÂÀ´,ɾ³ý¾ÉĿ¼,ÔÙÖØа²×°ORACLE,Ŀ¼ºÍ¾ÉĿ¼һÑù(Èç¹û²»Ò»Ñù,ÒªÐ޸ĵĵط½±È½Ï¶à).Ö»°²×°ORACLE,²»´´½¨Êý¾Ý¿â¡£Òª»Ö¸´µÄʵÀýΪORCL ¡£
2.ÓÃÃüÁʽ£¬Í¨¹ýÒª¾ÉµÄORAÎļþ´´½¨ÐµÄʵÀýORCL
a) oradim -new -sid ORCL£¨´´½¨ÊµÀý£ ......
1.²é¿´ËùÓÐÓû§
select * from all_users; -------²é¿´ËùÓеÄÓû§
select * from user_users; --------²é¿´µ±Ç°Óû§
2.²é¿´Óû§»ò½ÇɫϵͳȨÏÞ£º
select * from user_sys_privs; --------²é¿´µ±Ç°Óû§µÄȨÏÞ
3.²é¿´½ÇÉ«Ëù°üº¬µÄȨÏÞ
&nb ......