ORACLE SQLÐÔÄÜÓÅ»¯
ORACLE SQLÐÔÄÜÓÅ»¯
ÎÒÒª½²µÄÌâÄ¿ÊÇOracle SQLÐÔÄÜÓÅ»¯£¬Ö»ÊÇOracleÐÔÄÜÓÅ»¯ÖеÄÒ»Ïî¡£OracleµÄÐÔÄÜÓÅ»¯°üº¬ºÜ¶à·½Ã棬±ÈÈçµ÷ÕûÎïÀí´æÈ¡£¬µ÷ÕûÂß¼´æÈ¡£¬µ÷ÕûÄÚ´æʹÓ㬼õÉÙÍøÂçÁ÷Á¿µÈ¡£ÕâÀïÑ¡ÔñSQLÐÔÄÜÓÅ»¯ÊÇÒòΪÕⲿ·ÖÄÚÈÝÎÒÃDzâÊÔÈËÔ±×îÈÝÒ×½Ó´¥µ½£¬ÁíÍ⿪·¢ÈËԱдSQL½Å±¾Ê±ÓÐʱºÜËæÒ⣬²»Öª²»¾õ¾Í»áÔì³É³ÌÐòÐÔÄÜÉϵÄϽµ¡£
1£® Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû,Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí. ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í.µ±ORACLE´¦Àí¶à¸ö±íʱ, »áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á¬½ÓËüÃÇ.Ê×ÏÈ,ɨÃèµÚÒ»¸ö±í(from×Ó¾äÖÐ×îºóµÄÄǸö±í)²¢¶Ô¼Ç¼½øÐÐÅÉÐò,È»ºóɨÃèµÚ¶þ¸ö±í(from×Ó¾äÖÐ×îºóµÚ¶þ¸ö±í),×îºó½«ËùÓдӵڶþ¸ö±íÖмìË÷³öµÄ¼Ç¼ÓëµÚÒ»¸ö±íÖкÏÊʼǼ½øÐкϲ¢.
ÀýÈç:
±í TAB1 16,384 Ìõ¼Ç¼
±í TAB2 1 Ìõ¼Ç¼
Ñ¡ÔñTAB2×÷Ϊ»ù´¡±í (×îºÃµÄ·½·¨)
select count(*) from tab1,tab2 Ö´ÐÐʱ¼ä0.96Ãë
Ñ¡ÔñTAB2×÷Ϊ»ù´¡±í (²»¼ÑµÄ·½·¨)
select count(*) from tab2,tab1 Ö´ÐÐʱ¼ä26.09Ãë
Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄǾÍÐèҪѡÔñ½»²æ±í(intersection table)×÷Ϊ»ù´¡±í, ½»²æ±íÊÇÖ¸ÄǸö±»ÆäËû±íËùÒýÓõıí.
ÀýÈç:
EMP±íÃèÊöÁËLOCATION±íºÍCATEGORY±íµÄ½»¼¯.
SELECT *
from LOCATION L , CATEGORY C, EMP E
WHERE E.EMP_NO BETWEEN 1000 AND 2000
AND E.CAT_NO = C.CAT_NO
AND E.LOCN = L.LOCN
½«±ÈÏÂÁÐSQL¸üÓÐЧÂÊ
SELECT *
from EMP E ,
LOCATION L ,
CATEGORY C
WHERE E.CAT_NO = C.CAT_NO
AND E.LOCN = L.LOCN
AND E.EMP_NO BETWEEN 1000 AND 2000
2£® WHERE×Ó¾äÖеÄÁ¬½Ó˳Ðò£®
ORACLE²ÉÓÃ×Ô϶øÉϵÄ˳Ðò½âÎöWHERE×Ó¾ä,¸ù¾ÝÕâ¸öÔÀí,±íÖ®¼äµÄÁ¬½Ó±ØÐëдÔÚÆäËûWHEREÌõ¼þ֮ǰ, ÄÇЩ¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐëдÔÚWHERE×Ó¾äµÄĩβ.
ÀýÈç:
Ïà¹ØÎĵµ£º
oracle±í¿Õ¼ä²Ù×÷Ïê½â
1
2
3×÷Õߣº À´Ô´£º ¸üÐÂÈÕÆÚ£º2006-01-04
5
6
7½¨Á¢±í¿Õ¼ä
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
1.Ñ¡ÓÃÊʺϵÄOracleÓÅ»¯Æ÷
OracleµÄÓÅ»¯Æ÷¹²ÓÐ3ÖÖ£º
a.RULE(»ùÓÚ¹æÔò)
b.COST(»ùÓڳɱ¾)
c.CHOOSE(Ñ¡ÔñÐÔ)
ÉèÖÃȱʡµÄÓÅ»¯Æ÷£¬¿ÉÒÔͨ¹ý¶Ôinit.oraÎļþÖÐOPTIMIZER_MODE²ÎÊýµÄ
¸÷ÖÖÉùÃ÷£¬ÈçRULE¡¢COST¡¢CHOOSE¡¢ALL_ROWS¡¢FIRST_ROWS¡£Ä㵱ȻҲÔÚSQL¾ä¼¶»òÊǻỰ(session)¼¶¶ÔÆä½øÐи²
¸Ç¡£
ΪÁËʹÓûùÓڳɱ¾µÄÓÅ»¯Æ ......
¡¡¡¡1. Oracle°²裝Íê³ÉºóµÄ³õʼ¿ÚÁ
¡¡¡¡internal/oracle
¡¡¡¡sys/change_on_install
¡¡¡¡system/manager
¡¡¡¡scott/tiger
¡¡¡¡sysman/oem_temp
¡¡¡¡2. ORACLE9IAS WEB CACHEµÄ³õʼĬÈÏÓû§ºÍÃÜÂ룿
¡¡¡¡administrator/administrator
¡¡¡¡3. oracle 8.0.5Ôõô´´½¨Êý¾Ý¿â£¿
¡¡¡¡ÓÃorainst¡£Èç¹ûÓ ......
1¡¢ÓÉÓÚorcale10²»Ö§³Ö redhat as5 ÐèÒªÐÞ¸Ä/etc/redhat-realease ½« Red
Hat Enterprise Linux Server release 5 (Tikanga) ¸ÄΪRed Hat Enterprise
Linux Server release 4 (Tikanga) £¬°²×°Íê³ÉºóÔÙ½«ÆäÐ޸ĻØÀ´
2¡¢ÐÞ¸Ä/etc/hosts Îļþ½«127.0.0.1¸ÄΪ±¾»úIPµØÖ· ·ñÔòÍøÂç¼ì²éͨ²»¹ý
3¡¢¼ì² ......
SQL ÖеÄÖ÷¼üµÄ×÷ÓÃ:
Äܹ»Î¨Ò»±íʾÊý¾Ý±íÖеÄÿ¸ö¼Ç¼µÄ¡¾×ֶΡ¿»òÕß¡¾×ֶΡ¿µÄ×éºÏ¾Í³ÆΪÖ÷Âë(Ö÷¼ü)¡£
×÷ÓÃ
1¡¢Ö÷¼üΨһµÄʶ±ðÿһ¼Ç¼;
2¡¢Ö÷¼ü½«¼Ç¼ºÍ´æ·ÅÔÚÆäËû±íÖеÄÊý¾Ý½øÐйØÁª¡£ÔÚÕâÒ»µãÉÏ£¬Ö÷¼üÊDz»Í¬±íÖи÷¼Ç¼֮¼äµÄ¼òµ¥Ö¸Õë¡£
ÈôÓÐÁ½¸ö±íA£¬B£¬keyÊÇAµÄÖ÷¼ü£¬¶øBÖÐÒ²ÓÐkey×ֶΣ¬Ôòkey¾ÍÊDZíBµÄÍâ¼ü¡£
A ......