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

oracle ±Ê¼Ç IX Ö®ÄÚÁª¡¢×óÁª¡¢ÓÒÁª

½éÉÜÒ»ÏÂÄÚÁª¡¢×óÁª¡¢ÓÒÁª
Ò».ÏÈ¿´Ò»Ð©×î¼òµ¥µÄÀý×Ó
Àý×Ó
Table A
aid adate
1 a1
2 a2
3 a3
TableB
bid bdate
1 b1
2 b2
4 b4
Á½¸ö±ía,bÏàÁ¬½Ó,Ҫȡ³öidÏàͬµÄ×Ö¶Î
select * from a inner join b on a.aid = b.bidÕâÊǽöÈ¡³öÆ¥ÅäµÄÊý¾Ý.
´ËʱµÄÈ¡³öµÄÊÇ:
1 a1 b1
2 a2 b2
ÄÇôleft join Ö¸:
select * from a left join b on a.aid = b.bid
Ê×ÏÈÈ¡³öa±íÖÐËùÓÐÊý¾Ý,È»ºóÔÙ¼ÓÉÏÓëa,bÆ¥ÅäµÄµÄÊý¾Ý
´ËʱµÄÈ¡³öµÄÊÇ:
1 a1 b1
2 a2 b2
3 a3 ¿Õ×Ö·û
ͬÑùµÄÒ²ÓÐright join
Ö¸µÄÊÇÊ×ÏÈÈ¡³öb±íÖÐËùÓÐÊý¾Ý,È»ºóÔÙ¼ÓÉÏÓëa,bÆ¥ÅäµÄµÄÊý¾Ý
´ËʱµÄÈ¡³öµÄÊÇ:
1 a1 b1
2 a2 b2
4 ¿Õ×Ö·û b4
LEFT JOIN »ò LEFT OUTER JOIN¡£
×óÏòÍâÁª½ÓµÄ½á¹û¼¯°üÀ¨ LEFT OUTER ×Ó¾äÖÐÖ¸¶¨µÄ×ó±íµÄËùÓÐÐУ¬¶ø²»½ö½öÊÇÁª½ÓÁÐËùÆ¥ÅäµÄÐС£Èç¹û×ó±íµÄijÐÐÔÚÓÒ±íÖÐûÓÐÆ¥ÅäÐУ¬ÔòÔÚÏà¹ØÁªµÄ½á¹û¼¯ÐÐÖÐÓÒ±íµÄËùÓÐÑ¡
ÔñÁбíÁоùΪ¿ÕÖµ
¶þ. left join/right join/inner join²Ù×÷ÑÝʾ
±íA¼Ç¼ÈçÏ£º
aID aNum
1 a20050111
2 a20050112
3 a20050113
4 a20050114
5 a20050115
±íB¼Ç¼ÈçÏÂ:
bID bName
1 2006032401
2 2006032402
3 2006032403
4 2006032404
8 2006032408
ʵÑéÈçÏÂ:
1. left join
sqlÓï¾äÈçÏÂ:
SELECT * from A
LEFT JOIN B
ON A.aID = B.bID
½á¹ûÈçÏÂ:
aID aNum bID bName
1 a20050111 1 2006032401
2 a20050112 2 2006032402
3 a20050113 3 2006032403
4 a20050114 4 2006032404
5 a20050115 NULL NULL
£¨ËùÓ°ÏìµÄÐÐÊýΪ 5 ÐУ©
½á¹û˵Ã÷:
left joinÊÇÒÔA±íµÄ¼Ç¼Ϊ»ù´¡µÄ,A¿ÉÒÔ¿´³É×ó±í,B¿ÉÒÔ¿´³ÉÓÒ±í,left joinÊÇÒÔ×ó±íΪ׼µÄ.
»»¾ä»°Ëµ,×ó±í(A)µÄ¼Ç¼½«»áÈ«²¿±íʾ³öÀ´,¶øÓÒ±í(B)Ö»»áÏÔʾ·ûºÏËÑË÷Ìõ¼þµÄ¼Ç¼(Àý×ÓÖÐΪ: A.aID = B.bID).
B±í¼Ç¼²»×ãµÄµØ·½¾ùΪNULL.
2. right join
sqlÓï¾äÈçÏÂ:
SELECT * from A
RIGHT JOIN B
ON A.aID = B.bID
½á¹ûÈçÏÂ:
aID aNum bID bName
1 a20050111 1 2006032401
2 a20050112 2 2006032402
3 a20050113 3 2006032403
4 a20050114 4 2006032404
NULL NULL 8 2006032408
£¨ËùÓ°ÏìµÄÐÐÊýΪ 5 ÐУ©
½á¹û˵Ã÷:
×Ðϸ¹Û²ìÒ»ÏÂ,¾Í»á·¢ÏÖ,ºÍleft joinµÄ½á¹û¸ÕºÃÏà·´,Õâ´ÎÊÇÒÔÓÒ±í(B)Ϊ»ù´¡µÄ,A±í²»×ãµÄµØ·½ÓÃNULLÌî³ä.
3.inner join
sqlÓï¾äÈçÏÂ:
SELECT * from A
INNERJOIN B
ON A.aID = B.bID
½á¹ûÈçÏÂ:
aID aNum bID bName
1 a20050111 1 2006032401


Ïà¹ØÎĵµ£º

Ò»¸öÐÞ¸ÄOracleÓû§ÃÜÂëµÄС¾÷ÇÏ

 Êý¾Ý¿â°æ±¾£º9.2.0.5
¡¡¡¡ÓÐʱºòÎÒÃÇ¿ÉÄܲ»ÖªµÀÒ»¸öÓû§µÄÃÜÂ룬µ«ÊÇÓÖÐèÒªÒÔÕâ¸öÓû§×öһЩ²Ù×÷£¬ÓÖ²»ÄÜÈ¥Ð޸ĵôÕâ¸öÓû§µÄÃÜÂ룬Õâ¸öʱºò£¬¾Í¿ÉÒÔÀûÓÃһЩСÇÏÃÅ£¬À´Íê³É²Ù×÷¡£
¡¡¡¡¾ßÌå²Ù×÷¹ý³ÌÈçÏ£º
¡¡¡¡SQL*Plus: Release 9.2.0.5.0 - Production on ÐÇÆÚÈÕ 11ÔÂ 21 13:32:34 2004
¡¡¡¡Copyright (c) 1982, ......

Oracle Óï¾äÓÅ»¯30¸ö¹æÔò(ÉÏ)

1. Ñ¡ÓÃÊʺϵÄOracleÓÅ»¯Æ÷
¡¡¡¡OracleµÄÓÅ»¯Æ÷¹²ÓÐ3ÖÖ£º
¡¡¡¡a. RULE (»ùÓÚ¹æÔò)
¡¡¡¡b. COST (»ùÓڳɱ¾)
¡¡¡¡c. CHOOSE (Ñ¡ÔñÐÔ)
¡¡¡¡ÉèÖÃȱʡµÄÓÅ»¯Æ÷£¬¿ÉÒÔͨ¹ý¶Ôinit.oraÎļþÖÐOPTIMIZER_MODE²ÎÊýµÄ¸÷ÖÖÉùÃ÷£¬ÈçRULE£¬COST£¬CHOOSE£¬ALL_ROWS£¬FIRST_ROWS . Ä㵱ȻҲÔÚSQL¾ä¼¶»òÊǻỰ(session)¼¶¶ÔÆä½øÐи²¸Ç¡£ ......

Oracle Óï·¨Ö® OVER (PARTITION BY ..) ¼°¿ª´°º¯Êý


oracleµÄ·ÖÎöº¯Êýover ¼°¿ª´°º¯Êý
Ò»£º·ÖÎöº¯Êýover
Oracle´Ó8.1.6¿ªÊ¼Ìṩ·ÖÎöº¯Êý£¬·ÖÎöº¯ÊýÓÃÓÚ¼ÆËã»ùÓÚ×éµÄijÖÖ¾ÛºÏÖµ£¬ËüºÍ¾ÛºÏº¯ÊýµÄ²»Í¬Ö®´¦ÊÇ
¶ÔÓÚÿ¸ö×é·µ»Ø¶àÐУ¬¶ø¾ÛºÏº¯Êý¶ÔÓÚÿ¸ö×éÖ»·µ»ØÒ»ÐС£
ÏÂÃæͨ¹ý¼¸¸öÀý×ÓÀ´ËµÃ÷ÆäÓ¦Óᣠ          &nb ......

oracle ±Ê¼Ç VII Ö® ´óÊý¾ÝÁ¿ÏµķÖÒ³

 ÔÚORACLE ´óÊý¾ÝÁ¿ÏµķÖÒ³½â¾ö·½·¨¡£Ò»°ãÓýØÈ¡ID ·½·¨£¬»¹ÓÐÊÇÈý²ã ǶÌ×·½·¨
Ò»ÖÖ·ÖÒ³·½·¨
<%
    int i = 1;
    int numPages = 14;
    String pages = request.getParameter("page");
    int currentPage = 1;
    cu ......

oracle ±Ê¼Ç VIII Ö®ÊÂÎñºÍË÷Òý

 ÊÂÎñ¾ÍÊDZ»°ó¶¨ÔÚÒ»Æð×÷Ϊһ¸öÂß¼­¹¤×÷µ¥ÔªµÄSQLÓï¾ä·Ö×飬Èç¹ûÈκÎÒ»¸öÓï¾ä²Ù×÷ʧ°ÜÄÇôÕû¸ö²Ù×÷¾Í±»Ê§°Ü£¬ÒÔºó²Ù×÷¾Í»á»Ø¹öµ½²Ù×÷ǰ״̬£¬»òÕßÊÇÉÏÓиö½Úµã¡£ÎªÁËÈ·±£ÒªÃ´Ö´ÐУ¬ÒªÃ´²»Ö´ÐУ¬¾Í¿ÉÒÔʹÓÃÊÂÎñ¡£ÊÂÎñÓÐËĸöÌØÐÔ£¬·Ö±ðÊÇ£ºÔ­×ÓÐÔ£¬Ò»ÖÂÐÔ£¬¸ôÀëÐԺͳ־ÃÐÔ¡£
Ë÷Òý¾ÍÒ»ÖÖÌØÊâµÄ²éѯ±í£¬Êý¾Ý¿âµÄËÑË÷ÒýÇæ¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ