¡¾×ª¡¿ OracleÐÔÄÜÓÅ»¯¼¼ÇÉ
OracleÐÔÄÜÓÅ»¯¼¼ÇÉ
http://tech.it168.com/db/o/2006-06-15/200606151715426.shtml
1.Ñ¡ÓÃÊʺϵÄORACLEÓÅ»¯Æ÷
ORACLEµÄÓÅ»¯Æ÷¹²ÓÐ3ÖÖ:
1.RULE(»ùÓÚ¹æÔò) 2.COST(»ùÓڳɱ¾) 3.CHOOSE(Ñ¡ÔñÐÔ)
ÉèÖÃȱʡµÄÓÅ»¯Æ÷,¿ÉÒÔͨ¹ý¶Ôinit.oraÎļþÖÐOPTIMIZER_MODE²ÎÊýµÄ¸÷ÖÖÉùÃ÷,ÈçRULE,COST,CHOOSE,ALL_ROWS,FIRST_ROWS . Ä㵱ȻҲÔÚSQL¾ä¼¶»òÊǻỰ(session)¼¶¶ÔÆä½øÐи²¸Ç.
ΪÁËʹÓûùÓڳɱ¾µÄÓÅ»¯Æ÷(CBO, Cost-Based Optimizer) , Äã±ØÐë¾³£ÔËÐÐanalyze ÃüÁî,ÒÔÔö¼ÓÊý¾Ý¿âÖеĶÔÏóͳ¼ÆÐÅÏ¢(object statistics)µÄ׼ȷÐÔ.
Èç¹ûÊý¾Ý¿âµÄÓÅ»¯Æ÷ģʽÉèÖÃΪѡÔñÐÔ(CHOOSE),ÄÇôʵ¼ÊµÄÓÅ»¯Æ÷ģʽ½«ºÍÊÇ·ñÔËÐйýanalyzeÃüÁîÓйØ. Èç¹ûtableÒѾ±»analyze¹ý, ÓÅ»¯Æ÷ģʽ½«×Ô¶¯³ÉΪCBO , ·´Ö®,Êý¾Ý¿â½«²ÉÓÃRULEÐÎʽµÄÓÅ»¯Æ÷.
ÔÚȱʡÇé¿öÏÂ,ORACLE²ÉÓÃCHOOSEÓÅ»¯Æ÷, ΪÁ˱ÜÃâÄÇЩ²»±ØÒªµÄÈ«±íɨÃè(full table scan) , Äã±ØÐ뾡Á¿±ÜÃâʹÓÃCHOOSEÓÅ»¯Æ÷,¶øÖ±½Ó²ÉÓûùÓÚ¹æÔò»òÕß»ùÓڳɱ¾µÄÓÅ»¯Æ÷.
2.·ÃÎÊTableµÄ·½Ê½
ORACLE ²ÉÓÃÁ½ÖÖ·ÃÎʱíÖмǼµÄ·½Ê½:
1.È«±íɨÃè
È«±íɨÃè¾ÍÊÇ˳ÐòµØ·ÃÎʱíÖÐÿÌõ¼Ç¼. ORACLE²ÉÓÃÒ»´Î¶ÁÈë¶à¸öÊý¾Ý¿é(database block)µÄ·½Ê½ÓÅ»¯È«±íɨÃè.
2.ͨ¹ýROWID·ÃÎʱí
Äã¿ÉÒÔ²ÉÓûùÓÚROWIDµÄ·ÃÎÊ·½Ê½Çé¿ö,Ìá¸ß·ÃÎʱíµÄЧÂÊ, , ROWID°üº¬Á˱íÖмǼµÄÎïÀíλÖÃÐÅÏ¢..ORACLE²ÉÓÃË÷Òý(INDEX)ʵÏÖÁËÊý¾ÝºÍ´æ·ÅÊý¾ÝµÄÎïÀíλÖÃ(ROWID)Ö®¼äµÄÁªÏµ. ͨ³£Ë÷ÒýÌṩÁË¿ìËÙ·ÃÎÊROWIDµÄ·½·¨,Òò´ËÄÇЩ»ùÓÚË÷ÒýÁеIJéѯ¾Í¿ÉÒԵõ½ÐÔÄÜÉϵÄÌá¸ß.
3.¹²ÏíSQLÓï¾ä
ΪÁ˲»Öظ´½âÎöÏàͬµÄSQLÓï¾ä,ÔÚµÚÒ»´Î½âÎöÖ®ºó, ORACLE½«SQLÓï¾ä´æ·ÅÔÚÄÚ´æÖÐ.Õâ¿éλÓÚϵͳȫ¾ÖÇøÓòSGA(system global area)µÄ¹²Ïí³Ø(shared buffer pool)ÖеÄÄÚ´æ¿ÉÒÔ±»ËùÓеÄÊý¾Ý¿âÓû§¹²Ïí. Òò´Ë,µ±ÄãÖ´ÐÐÒ»¸öSQLÓï¾ä(ÓÐʱ±»³ÆΪһ¸öÓαê)ʱ,Èç¹ûËüºÍ֮ǰµÄÖ´ÐйýµÄÓï¾äÍêÈ«Ïàͬ, ORACLE¾ÍÄܺܿì»ñµÃÒѾ±»½âÎöµÄÓï¾äÒÔ¼°×îºÃµÄÖ´Ðз¾¶. ORACLEµÄÕâ¸ö¹¦ÄÜ´ó´óµØÌá¸ßÁËSQLµÄÖ´ÐÐÐÔÄܲ¢½ÚÊ¡ÁËÄÚ´æµÄʹÓÃ.
¿ÉϧµÄÊÇORACLEÖ»¶Ô¼òµ¥µÄ±íÌṩ¸ßËÙ»º³å(cache buffering)
Ïà¹ØÎĵµ£º
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE hibernate-configuration (View Source for full doctype...)>
- <!-- Generated by MyEclipse Hibernate Tools.
--> - <!-- ÒÔÉϼ¸ÐÐËùÓеÄhibernate.cfg.xml¶¼Ïàͬ
--> [url=file:///C:/Documents%20and%20Settings/ ......
¾³£ÔÚƽʱµÄ¿ª·¢ÖÐÒªÓõ½oracleµÄÈÕÆÚº¯Êý£¬Ã¿´Î¶¼ÒªÉÏÍøÈ¥²é£¬ÏÖÔÚÓеãʱ¼ä£¬×Ô¼ºÊÕ¼¯ÕûÀíÁËһϡ£ÌùÔÚÕâÀ·½±ã×Ô¼º£¬Ò²·½±ã´ó¼Ò¡£
----------------------------------------------------------------------------------------------------------------------------------
³£ÓÃÈÕÆÚÐͺ¯Êý
1¡£Sysdate µ±Ç°È ......
#! /bin/bash
if [ -f ~/.bashrc ];then
. ~/.bash_profile
fi
export script=/home/oracle/script
export bakdata_destination=/u02/rman_backup/data
export baklog_destination=/u02/rman_backup/log
export datadir=`date +'%Y_%m_%d'`
export days=`date +'%w'`
if ! test -d $script
then
&nb ......
1¡¢»ù±¾Óï·¨
SELECT
from
WHERE
GROUP BY
HAVING
ORDER BY
SELECT:²éѯµÄ×Ö¶Î
1¡¢¿ÉÓÃ*±íʾËùÓÐ×ֶΡ£
2¡¢×Ö¶ÎÖ®¼äÓöººÅ·Ö¸î¡£
3¡¢¿ÉΪ×Ö¶ÎÆð±ðÃû Æä±ðÃû¿Éд³ÉSELECT AAAA¡£AA AS SS »ò AAAA¡£AA SS ¿ÉÊ¡ÂÔas
4¡¢¿ÉÖ±½Óд×Ö¶ÎÖµ£ºÈç SELECT AAAA¡£AA SS,'ÕÅÈý' NAME from ¡£¡£¡£
from:²éѯµÄ±íÃû
1¡¢±íà ......
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on ÐÇÆÚ¶þ 10ÔÂ 13 15:26:31 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Á¬½Óµ½:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partition ......