ORACLE REDO ¡¶ÉîÈëdz³öORACLEµÚÁùÕ¡·
RedoµÄÄÚÈÝ
Oracleͨ¹ýRedoÀ´ÊµÏÖ¿ìËÙÌá½»£¬Ò»·½ÃæÊÇÒòΪRedo Log File¿ÉÒÔÁ¬Ðø¡¢Ë³ÐòµØ¿ìËÙд³ö£¬ÁíÒ»¸ö·½ÃæÒ²ºÍRedo¼Ç¼µÄ¾«¼òÄÚÈÝÓйء£
Á½¸ö¸ÅÄ
¸Ä±äÏòÁ¿£¨Change Vector£©
¸Ä±äÏòÁ¿±íʾ¶ÔÊý¾Ý¿âÄÚijһ¸öÊý¾Ý¿éËù×öµÄÒ»´Î±ä¸ü¡£¸Ä±äÏòÁ¿Öаüº¬Á˱ä¸üµÄÊý¾Ý¿éµÄ°æ±¾ºÅ¡¢ÊÂÎñ²Ù×÷´úÂë¡¢±ä¸ü´ÓÊôÊý¾Ý¿éµÄµØÖ·£¨DBA£©ÒÔ¼°¸üкóµÄÊý¾Ý¡£ÀýÈ磺һ¸öupdateÊÂÎñ°üº¬Ò»ÏµÁеĸıäÏòÁ¿£¬¶ÔÓÚÊý¾Ý¿éµÄÐÞ¸ÄÊÇÒ»¸öÏòÁ¿£¬¶ÔÓڻعö¶ÎµÄÐÞ¸ÄÓÖÊÇÒ»¸öÏòÁ¿¡£
ÖØ×ö¼Ç¼£¨Redo Record£©
ÖØ×ö¼Ç¼ͨ³£ÓÉÒ»×é¸Ä±äÏòÁ¿×é³É£¬ÊÇÒ»¸ö¸Ä±äÏòÁ¿µÄ¼¯ºÏ£¬´ú±íÒ»¸öÊý¾Ý¿âµÄ±ä¸ü£¨INSERT¡¢UPDATE¡¢DELETEµÈ²Ù×÷£©£¬¹¹³ÉÊý¾Ý¿â±ä¸üµÄ×îС»Ö¸´µ¥Î»¡£ÀýÈ磺һ¸öUpdateµÄÖØ×ö¼Ç¼°üÀ¨ÏàÓ¦µÄ»Ø¹ö¶ÎµÄ¸Ä±äÏòÁ¿ºÍÏàÓ¦µÄÊý¾Ý¿éµÄ¸Ä±äÏòÁ¿µÈ¡£
¼Ù¶¨·¢³öÒ»¸ö¸üÐÂÓï¾ä£º
Update emp set sal=4000 where empno=7788;
Õâ¸öÓï¾äµÄÖ´ÐÐÈçÏÂËùʾ£º
¼ì²éempno=7788¼Ç¼ÔÚBuffer CacheÖÐÊÇ·ñ´æÔÚ£¬Èç¹û²»´æÔÚÔò¶ÁÈ¡µÀBuffer CacheÖУ»
Ôڻعö¶Î±í¿Õ¼äµÄÏàÓ¦»Ø¹ö¶ÎÊÂÎñ±íÉÏ·ÖÅäÊÂÎñ²Û£¬Õâ¸ö²Ù×÷ÐèÒª¼Ç¼RedoÐÅÏ¢£»
´Ó»Ø¹ö¶Î¶ÁÈë»òÕßÔÚBuffer CacheÖд´½¨sal=3000µÄÇ°¾µÏñ£¬ÕâÐèÒª²úÉúRedoÐÅÏ¢²¢¼ÇÈëRedo Log Buffer£»
ÐÞ¸Äsal=4000£¬ÕâÊÇupdateµÄÊý¾Ý±ä¸ü£¬ÐèÒª¼ÇÈëRedo Log Buffer;
µ±Óû§Ìύʱ£¬»áÔÚRedo Log Buffer¼Ç¼Ìá½»ÐÅÏ¢£¬²¢Ôڻعö¶Î±ê¼Ç¸ÃÊÂÎñΪ·Ç¼¤»î¡£
¶ÔÓÚÊý¾Ý¿éµÄÐ޸ģ¬Èç¹ûÖ´ÐÐд³ö£¬ÄÇôͨ³£ÐèҪд³ö8KBµÄBlock£¬¶ø¶ÔÓÚRedoÈÕÖ¾À´Ëµ£¬ÖØ×öÐÅϢȴÏ൱¾«¼ò£¬OracleÖ»ÐèÒª¼Ç¼ÄÇЩÖع¹ÊÂÎñ±ØÐëµÄÐÅÏ¢£¨ÈçÊÂÎñºÅ¡¢ÎļþºÅ¡¢¿éºÅ¡¢Ðкš¢×ֶεȣ©¼´¿É£¬Õâ¸öÊý¾ÝÁ¿´ó´ó¼õÉÙ¡£
²úÉú¶àÉÙRedo
ÔÚSQL*PlusÖÐʹÓÃautotrace¹¦ÄÜ
µ±ÔÚSQL*PlusÖÐÆôÓÃautotrace¸ú×Ùºó£¬ÔÚÖ´ÐÐÁËÌض¨µÄDMLÓï¾äʱ£¬Oracle»áÏÔʾ¸ÃÓï¾äµÄͳ¼ÆÐÅÏ¢£¬ÆäÖУ¬Redo sizeÒ»À¸±íʾµÄ¾ÍÊǸòÙ×÷²úÉúµÄRedoµÄÊýÁ¿£º
SQL> set autotrace trace stat
SQL> insert into test
2 select empno,ename from scott.emp;
ÒÑ´´½¨12ÐС£
Statistics
----------------------------------------------------------
189 recursive calls
2 db block gets
37 consistent gets
4 physical
Ïà¹ØÎĵµ£º
Ò»¡¢×¼±¸ÌØÊâÊý¾Ý
create table t_escape(s varchar2(50));
--show define -- define "&" (hex 26)
--show escape -- escape off
set define off
set escape on
insert into t_escape values('string&text');
insert into t_escape values('string\&text');
insert into t_escape values('st ......
1.Çó²¿ÃÅÖÐÄÄЩÈËнˮ×î¸ß£º
select ename,sal
from emp join
(
select max(sal) max_sal, deptno
from emp
group by deptno
) t
on (emp.sal = t.max_sal and emp.deptno = t.deptno);
2.Çó²¿ÃÅƽ¾ùнˮµÄµÈ¼¶£º
select deptno, avg_sal, grade ......
1¡¢Èç¹ûÓÐÒ»¶¨µÄÊý¾Ý¿â»ù´¡£¬ÖªµÀSQLÊÇÔõô»ØÊ£¬¼´Ê¹Ð´²»³öÀ´¼òµ¥µÄSQL£¬µ«¿ÉÒÔ¿´¶¯ËüÃÇ£¬Äã¾Í¿ÉÒÔÌøµ½2¡£·ñÔòÇëÏÈ¿´Ò»ÏÂÊý¾Ý¿â»ù´¡ºÍSQLÓïÑÔ£¬²»ÐèÒªºÜÉ¸ü²»ÐèҪȥ¼ÇÒäÄÇЩ¸´ÔÓµÄSQLÃüÁÕâЩ¿ÉÒÔÁôÔÚÒÔºó±ßÓ¦Óñßѧϰ¡¢¼ÇÒä¡£
¡¡¡¡
¡¡¡¡2¡¢ÒªÏëѧºÃORACLE£¬Ê×ÏÈҪѧϰORACLEµÄÌåϵ½á¹¹£¬ÏÖÔÚÄã²»ÐèÒªÉîÈëÀ ......
¶ÔÓÚrownumÀ´ËµËüÊÇoracleϵͳ˳Ðò·ÖÅäΪ´Ó²éѯ·µ»ØµÄÐеıàºÅ£¬·µ»ØµÄµÚÒ»ÐзÖÅäµÄÊÇ1£¬µÚ¶þÐÐÊÇ2£¬ÒÀ´ËÀàÍÆ£¬Õâ¸öα×ֶοÉÒÔÓÃÓÚÏÞÖƲéѯ·µ»ØµÄ×ÜÐÐÊý£¬¶øÇÒrownum²»ÄÜÒÔÈκαíµÄÃû³Æ×÷Ϊǰ׺¡£
¾ÙÀý˵Ã÷£º
ÀýÈç±í£ºstudent(ѧÉú)±í£¬±í½á¹¹Îª£º
ID¡¡¡¡¡¡ char(6)¡¡¡¡¡¡¡¡¡¡ --ѧºÅ
name¡¡¡¡ ......
IDÊÇÖ÷½¡£¬ÊµÏÖ²åÈëÒ»¸öNAME,ID×Ô¶¯Ôö¼Ó
SQL> create table t1
2 (
3 id & ......