Óú¯ÊýʵÏÖoracleµÄsys_connect_by_path¹¦ÄÜ
1.½¨±í£¬²åÈëÊý¾Ý
create table dept(deptno number,deptname varchar2(20),mgrno number);
insert into dept values(1,'×ܹ«Ë¾',null);
insert into dept values(2,'Õã½·Ö¹«Ë¾',1);
insert into dept values(3,'º¼ÖÝ·Ö¹«Ë¾',2);
insert into dept values(4,'ºþ±±·Ö¹«Ë¾',1);
insert into dept values(5,'Î人·Ö¹«Ë¾',4);
2.oracle²éѯÓï¾ä
select *,sys_connect_by_path(deptname,'/') deptname from dept
start with mgrno is null connect by prior deptno=mgrno;
----------------------------------------------------------------------------------------
1 ×ܹ«Ë¾ <NULL> /×ܹ«Ë¾
2 Õã½·Ö¹«Ë¾ 1 /×ܹ«Ë¾/Õã½·Ö¹«Ë¾
3 º¼ÖÝ·Ö¹«Ë¾ 2 /×ܹ«Ë¾/Õã½·Ö¹«Ë¾/º¼ÖÝ·Ö¹«Ë¾
4 ºþ±±·Ö¹«Ë¾ 1 /×ܹ«Ë¾/ºþ±±·Ö¹«Ë¾
5 Î人·Ö¹«Ë¾ 4 /×ܹ«Ë¾/ºþ±±·Ö¹«Ë¾/Î人·Ö¹«Ë¾
----------------------------------------------------------------------------------------
3.´´½¨º¯ÊýʵÏÖÀàËÆ¹¦ÄÜ
CREATE or replace FUNCTION Branch
( vdeptname varchar(200),
vDelimiter IN VARCHAR(10) DEFAULT '/')
return varchar(4000)
as
c1 cursor;
temp varchar(4000);
vename varchar(200);
begin
temp=vDelimiter;
open c1 for select deptname from dept start with deptname
=vdeptname connect by deptno= prior mgrno;
loop
FETCH
Ïà¹ØÎĵµ£º
ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
Ê×ÏÈ£¬Ô ......
1.ÔÚ±íÖ®¼ä´«ÊäÊý¾Ý
1£©ÀûÓÃINSERT´«ÊäÊý¾Ý
insert into test1 (select name2,age2 from test2);
´ÓÉÏÃæµÄ²Ù×÷¿ÉÒÔ¿´³ö£¬¿Éͨ¹ýSELECTÏòÒ»¸ö±íÖгÉÅúµØÌí¼ÓÊý¾Ý£¬µ«Ó¦×¢Ò⣺Êý¾ÝÀàÐÍÒªÒ»Ö£¬ËùÑ¡ÔñµÄÁÐÊýÓ¦Ò»Ö¡£´ËÓï¾äµÄÓï·¨¸ñʽÈçÏ£º
INSERT INTO table_name (
SELECT statement
) ;
2£©»ùÓÚÒÑÓÐµÄ±í½¨Á¢Ð ......
SQLÖеĵ¥¼Ç¼º¯Êý
1.ASCII
·µ»ØÓëÖ¸¶¨µÄ×Ö·û¶ÔÓ¦µÄÊ®½øÖÆÊý;
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;
A A ZERO ......
OracleÖд´½¨Í¬Òå´ÊÓï¾ä£º
create synonym table_name for user.table_name;
ÆäÖеÚÒ»¸öuser_tableºÍµÚ¶þ¸öuser_table¿ÉÒÔ²»Ò»Ñù¡£
´ËÍâÈç¹ûÒª´´½¨Ò»¸öÔ¶³ÌµÄÊý¾Ý¿âÉϵÄijÕűíµÄͬÒå´Ê£¬ÐèÒªÏÈ´´½¨Ò»¸öDatabase Link£¨Êý¾Ý¿âÁ¬½Ó£©À´À©Õ¹·ÃÎÊ£¬È»ºóÔÚʹÓÃÈçÏÂÓï¾ä´´½¨Êý¾Ý¿âͬÒå´Ê£ºcreate synonym tabl ......
±í´Ø£¨table cluster)ÊÇÒ»¸öÊý¾Ý¿â¶ÔÏó£¬Ëü¿ÉÒÔ½«ÄÇЩ¾³£ÔÚÏàͬÊý¾Ý¿éÖÐÒ»ÆðʹÓÃµÄ±í½øÐÐÎïÀí·Ö×é¡£µ±Äã´¦ÀíÄÇЩ¾³£Á¬½ÓÔÚÒ»Æð½øÐвéѯµÄ±íʱ£¬±í´ØÊÇÌØ±ðÓÐЧµÄ¡£Ò»¸ö±í´Ø´æ´¢´Ø¼ü£¨ÓÃÓÚ½«±íÁ¬½Óµ½Ò»ÆðµÄÁУ©£¬ÒÔ¼°´Ø±íÖеÄÁÐÖµ¡£ÒòΪ´ØÖÐµÄ±í¶¼±»´¢´æÔÚÏàͬµÄÊý¾Ý¿â¿éÖУ¬ËùÒÔʹÓôع¤×÷ʱ£¬I/O²Ù×÷¾Í¼õÉÙÁË¡£
......