OracleÖÐ×éºÏË÷ÒýµÄʹÓÃÏê½â
ÔÚOracleÖпÉÒÔ´´½¨×éºÏË÷Òý£¬¼´Í¬Ê±°üº¬Á½¸ö»òÁ½¸öÒÔÉÏÁеÄË÷Òý¡£ÔÚ×éºÏË÷ÒýµÄʹÓ÷½Ã棬OracleÓÐÒÔÏÂÌص㣺
1¡¢ µ±Ê¹ÓûùÓÚ¹æÔòµÄÓÅ»¯Æ÷£¨RBO£©Ê±£¬Ö»Óе±×éºÏË÷ÒýµÄÇ°µ¼ÁгöÏÖÔÚSQLÓï¾äµÄwhere×Ó¾äÖÐʱ£¬²Å»áʹÓõ½¸ÃË÷Òý£»
2¡¢ ÔÚʹÓÃOracle9i֮ǰµÄ»ùÓڳɱ¾µÄÓÅ»¯Æ÷£¨CBO£©Ê±£¬
Ö»Óе±×éºÏË÷ÒýµÄÇ°µ¼ÁгöÏÖÔÚSQLÓï¾äµÄwhere×Ó¾äÖÐʱ£¬²Å¿ÉÄÜ»áʹÓõ½¸ÃË÷Òý£¬ÕâÈ¡¾öÓÚÓÅ»¯Æ÷¼ÆËãµÄʹÓÃË÷ÒýµÄ³É±¾ºÍʹÓÃÈ«±íɨÃèµÄ³É
±¾£¬Oracle»á×Ô¶¯Ñ¡Ôñ³É±¾µÍµÄ·ÃÎÊ·¾¶£¨Çë¼ûÏÂÃæµÄ²âÊÔ1ºÍ²âÊÔ2£©£»
3¡¢ ´ÓOracle9iÆð£¬OracleÒýÈëÁËÒ»ÖÖеÄË÷ÒýɨÃ跽ʽ——Ë÷ÒýÌøԾɨÃ裨index skip
scan£©£¬ÕâÖÖɨÃ跽ʽֻÓлùÓڳɱ¾µÄÓÅ»¯Æ÷£¨CBO£©²ÅÄÜʹÓá£ÕâÑù£¬µ±SQLÓï¾äµÄwhere×Ó¾äÖм´Ê¹Ã»ÓÐ×éºÏË÷ÒýµÄÇ°µ¼ÁУ¬²¢ÇÒË÷ÒýÌøԾɨÃèµÄ
³É±¾µÍÓÚÆäËûɨÃ跽ʽµÄ³É±¾Ê±£¬Oracle¾Í»áʹÓø÷½Ê½É¨Ãè×éºÏË÷Òý£¨Çë¼ûÏÂÃæµÄ²âÊÔ3£©£»
4¡¢ OracleÓÅ»¯Æ÷ÓÐʱ»á×ö³ö´íÎóµÄÑ¡Ôñ£¬ÒòΪËüÔÙ“´ÏÃ÷”£¬Ò²²»ÈçÎÒÃÇSQLÓï¾ä±àдÈËÔ±¸üÇå³þ±íÖÐÊý¾ÝµÄ·Ö²¼£¬ÔÚÕâÖÖÇé¿öÏ£¬Í¨¹ýʹÓÃÌáʾ£¨hint£©£¬ÎÒÃÇ¿ÉÒÔ°ïÖúOracleÓÅ»¯Æ÷×÷³ö¸üºÃµÄÑ¡Ôñ£¨Çë¼ûÏÂÃæµÄ²âÊÔ4£©¡£
¹ØÓÚÒÔÉÏÇé¿ö£¬ÎÒÃÇ·Ö±ð²âÊÔÈçÏ£º
ÎÒÃÇ´´½¨²âÊÔ±íT£¬¸Ã±íµÄÊý¾ÝÀ´Ô´ÓÚOracleµÄÊý¾Ý×Öµä±íall_objects£¬±íTµÄ½á¹¹ÈçÏ£º
SQL> desc t
Ãû³Æ ÊÇ·ñΪ¿Õ? ÀàÐÍ
----------------------------------------- -------- ---------------------
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(18)
CREATED NOT NULL DATE
LAST_DDL_TIME NOT NULL DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
±íÖеÄÊý¾Ý·Ö²¼Çé¿öÈçÏ£º
SQL> select object_type,count(*) from t group by object_type;
OBJECT_TYPE COUNT(*)
------------------ ----------
CONSUMER GROUP 20
EVALUATION CONTEXT 10
FUNCTION 360
INDEX 69
LIBRARY 20
LOB 20
OPERATOR 20
PACKAGE 1210
PROCEDURE 130
SYNONYM 16100
TABLE 180
TYPE 2750
VIEW 8600
ÒÑÑ¡Ôñ13ÐС£
SQL> select
Ïà¹ØÎĵµ£º
1. round(Num,n) : ËÄÉáÎåÈëÊý×ÖNum£¬±£ÁônλСÊý£¬²»Ð´NĬÈϲ»ÒªÐ¡Êý£¬ËÄÉáÎåÈëµ½ÕûÊý¸öλ
select ROUND(21.237,2) from dual;
½á¹û£º 21.24
2. trunc(Num,n) : ½ØÈ¡Êý×ÖNum£¬±£ÁônλСÊý£¬²»Ð´NĬÈÏÊÇ0£¬¼´²»ÒªÐ¡Êý
select TRUNC(21.237,2) from dual;
½á¹û£º21.2 ......
DML Error Logging in Oracle 10g
Ö÷ÒªÔÚÓÚʹÓÃDBMS_ERRLOG.create_error_log Õâ¸ö°üÀ´¸ú×Ùdml´íÎóÐÅÏ¢
SQL> CREATE TABLE source (
2 id NUMBER(10) NOT NULL,
3 code VARCHAR2(10),
4 description VARCHAR2(50),
5 CONSTRAINT source_pk PRIMARY KEY (id)
6 );
±íÒÑ´´½¨¡£
SQL> DECLARE
2 TYPE t_tab IS ......
select sysdate from dual; ´Óα±í²éϵͳʱ¼ä£¬ÒÔĬÈϸñʽÊä³ö¡£
sysdate+(5/24/60/60) ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ãë
sysdate+5/24/60 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5·ÖÖÓ
sysdate+5/24 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Сʱ
sysdate+5 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ìì
ËùÒÔÈÕÆÚ¼ÆËãĬÈϵ¥Î»ÊÇÌì
round (sysdate,’day’) ²»ÊÇËijý ......
Ç°¼¸Ìì²Ù×÷Öз¢Ïֵģ¬Ò²²»ÖªµÀÊDz»ÊÇÎÒûÓиÄÅäÖû¹ÊÇÔõôµÄ£¬ÎÒ±¾È˵ÄÊý¾Ý¿â¾ÍÊÇĬÈÏ°²×°µÄ£¬È»ºó½«scottÓû§½âËøÁË£¬scottÓû§Ó¦¸ÃÊÇÆÕͨÓû§£¬¶ø²»ÊÇDBAÓû§¡£°´ÕÕ³£Àí·ÖÎö˵£¬ËûÓ¦¸ÃÊDz»ÊÇÄܹ»½øÈëϵͳ£¬Ò»°ãµÄʱºò£¬É趨ȨÏÞµÄʱºò¶¼»áÕâÑùÉè¡£
ÎÒ½«excelµÄÊý¾Ýµ¼ÈëoracleÖУ¬Ö´ÐеÄÈÕÖ¾Îļ ......
OracleµÄsql*plusÊÇÓëoracle½øÐн»»¥µÄ¿Í»§¶Ë¹¤¾ß¡£ÔÚsql*plusÖУ¬¿ÉÒÔÔËÐÐsql*plusÃüÁîÓësql*plusÓï¾ä¡£
¡¡¡¡
¡¡¡¡ÎÒÃÇͨ³£Ëù˵µÄDML¡¢DDL¡¢DCLÓï¾ä¶¼ÊÇsql*plusÓï¾ä£¬ËüÃÇÖ´ÐÐÍêºó£¬¶¼¿ÉÒÔ±£´æÔÚÒ»¸ö±»³ÆΪsql bufferµÄÄÚ´æÇøÓòÖУ¬²¢ÇÒÖ»Äܱ£´æÒ»Ìõ×î½üÖ´ÐеÄsqlÓï¾ä£¬ÎÒÃÇ¿ÉÒÔ¶Ô±£´æÔÚsql bufferÖеÄsql Óï¾ä½ø ......