Oracleµ÷¶È³ÌÐò×÷Òµdbms_scheduler
¡¡¡¡Oracle 10gÒýÈëdbms_schedulerÀ´Ìæ´úÏÈǰµÄdbms_job,ÔÚ¹¦ÄÜ·½Ãæ,Ëü±Èdbms_jobÌṩÁ˸üÇ¿´óµÄ¹¦Äܺ͸üÁé»îµÄ»úÖÆ/¹ÜÀí¡£
¡¡¡¡ÕûÀíschedulerÕâÒ»²¿·Ö,Ô´ÓÚ×î½ü·¢ÏÖϵͳÉÏ×Ô¶¯²É¼¯Í³¼ÆÐÅÏ¢µÄÖ´ÐÐʱ¼äÓÐЩÒì³£,Ö´ÐÐʱ¼ä±»¶¨Òåµ½ÁËÉÏÎç(Õâ²¢²»ÊÇÒ»¸öºÜºÏÀí¿É¿¿µÄʱ¼ä).ÔÚÖØÐÂÐÞ¸ÄÅäÖõÄͬʱ,Ҳ˳±ãÕûÀíÁËÕâÒ»¿éÄÚÈÝ.
¡¡¡¡Ê×Ïȼòµ¥½²Ò»ÏÂoracle 10g scheduler,10gÒýÈëdbms_schedulerÀ´Ìæ´úÏÈǰµÄdbms_job,ÔÚ¹¦ÄÜ·½Ãæ,Ëü±Èdbms_jobÌṩÁ˸üÇ¿´óµÄ¹¦Äܺ͸üÁé»îµÄ»úÖÆ/¹ÜÀí.ËüÖ÷ÒªÓÉÒÔϼ¸´ó¿é¹¹³É:
¡¡¡¡1.×÷Òµ(job):
¡¡¡¡Ò»¸öµ÷¶È³ÌÐò×÷ÒµµÄʵÌå.¿ÉÒÔÓÉdbms_scheduler.create_job´´½¨Éú³É.Ëü¿ÉÒÔ×ÔÐÐÖ¸¶¨×÷ÒµÊôÐÔ,Ò²¿ÉÒÔµ÷ÓÃÎÒÃÇÔ¤ÏÈ´´½¨µÄһϵÁÐscheduler/ program/ chain/ job_class/ window/ window_groupÀ´Æ¥ÅäÆä×÷ÒµÊôÐÔ.
¡¡¡¡2.µ÷¶È(scheduler):
¡¡¡¡Ò»¸öÈÎÎñ¼Æ»®Ö´ÐеÄʱ¼ä²ßÂÔ.±ÈÈçÎÒÃÇÏëÒª´´½¨Ò»¸öÍíÉÏ3µãÖ´ÐеÄÈÎÎñ¼Æ»®,¾Í¿ÉÒÔ´´½¨Ò»¸öµ÷¶È,·²ÊÇ·ûºÏÕâ¸öµ÷¶ÈÒªÇóµÄ,¶¼¿ÉÒÔµ÷ÓÃÕâ¸öÎÒÃÇÔ¤ÏÈ´´½¨ºÃµÄµ÷¶È.¿ÉÒÔÓÃdbms_scheduler.create_scheduleÀ´´´½¨Ò»¸öµ÷¶È.
¡¡¡¡±ÈÈçÎÒ´´½¨Ò»¸öÃû×Ö½ÐMYTEST_SCHEDULEµÄµ÷¶È,ÿÌì4:00Ö´ÐÐ.
¡¡¡¡Begin
¡¡¡¡dbms_scheduler.create_schedule(
¡¡¡¡repeat_interval => 'FREQ=DAILY;BYHOUR=4;BYMINUTE=0;BYSECOND=0',
¡¡¡¡start_date => systimestamp at time zone 'PRC',
¡¡¡¡comments => '---this is my test schedule---',
¡¡¡¡schedule_name => 'MYTEST_SCHEDULE');
¡¡¡¡end;
¡¡¡¡3.³ÌÐò(program):
¡¡¡¡10gϵÄprogramÖ§³Ö·ÖΪ3ÖÖÐÎʽ,PL/SQL BLOCK/STORED PROCEDURE/EXECUTABLE.¿ÉÒÔʹÓÃDBMS_SCHEDULER.CREATE_PROGRAMÀ´´´½¨Ò»¸öprogram.
¡¡¡¡BEGIN
¡¡¡¡DBMS_SCHEDULER.CREATE_PROGRAM(
¡¡¡¡program_name=>'mytest_program_1',
¡¡¡¡program_action=>'update mytest set id=id+1;',
¡¡¡¡program_type=>'PLSQL_BLOCK',
¡¡¡¡number_of_arguments=>0,
¡¡¡¡comments=>'',
¡¡¡¡enabled=>TRUE);
¡¡¡¡END;
¡¡¡¡4.Á´(chain):
¡¡¡¡Á´¿ÉÒÔ¿´×÷ÊÇÒ»¸ö/¼¸¸öprogram/event schedulerµÄ¼¯ºÏ,ΪÁËά»¤ÐèÒª,ÎÒÃÇ¿ÉÄÜÐèÒª½«ºÜ¶à²»Í¬µÄprogram·Åµ½Ò»ÆðÒÀ´ÎÖ´ÐÐ,°´ÕÕÒÔǰµÄģʽ,Ҫô½«Õ⼸¸öprogramÄÜÕûºÏ³ÉÒ»¸ö´óµÄÕûÌå,Ҫô·Ö¿ª¼¸¸öjobÀ´µ¥¶ÀÖ´ÐÐ,ÕâÎÞÒ
Ïà¹ØÎĵµ£º
OracleϵÁУºLOB´ó¶ÔÏó´¦Àí
Ö÷ÒªÊÇÓÃÀ´´æ´¢´óÁ¿Êý¾ÝµÄÊý¾Ý¿â×ֶΣ¬×î´ó¿ÉÒÔ´æ´¢4G×ֽڵķǽṹ»¯Êý¾Ý¡£
Ö÷Òª½éÉÜ×Ö·ûÀàÐͺͶþ½øÖÆÎļþÀàÐÍLOBÊý¾ÝµÄ´æ´¢£¬µ¥¶À½éÉܶþ½øÖÆÀàÐÍLOBÊý¾ÝµÄ´æ´¢¡£
Ò»£¬OracleÖеÄLOBÊý¾ÝÀàÐÍ·ÖÀà
1£¬°´´æ´¢Êý¾ÝµÄÀàÐÍ·Ö£º
¢Ù×Ö·ûÀàÐÍ£º
&nbs ......
FORALLÓï¾äµÄÒ»¸ö¹Ø¼üÐԸĽø£¬Ëü¿É´ó´ó¼ò»¯´úÂ룬²¢ÇÒ¶ÔÓÚÄÇЩҪÔÚPL/SQL³ÌÐòÖиüкܶàÐÐÊý¾ÝµÄ³ÌÐòÀ´Ëµ£¬Ëü¿ÉÏÔÖøÌá¸ßÆäÐÔÄÜ¡£
1:
ÓÃFORALLÀ´ÔöÇ¿DMLµÄ´¦ÀíÄÜÁ¦
OracleΪOracle8iÖеÄPL/SQLÒýÈëÁËÁ½¸öеÄÊý¾Ý²Ù×ÝÓïÑÔ£¨DML£©Óï¾ä£ºBULK COLLECTºÍFORALL¡£ÕâÁ½¸öÓï¾äÔÚPL/SQLÄÚ²¿½øÐÐÒ»ÖÖÊý×é´¦Àí
£»BULK COLLE ......
×î½üÒ»¶Îʱ¼äһֱûд²©¿Í£¬²»ÊÇÀÁ£¬ÊÇѧÁËÌ«¶à¶«Î÷¡£ÒÔºóÂýÂý²¹ÉÏ¡£ 1. odbcÖÐÌí¼ÓoracleÊý¾ÝÔ´ odbcÖÐÌí¼ÓoracleÊý¾ÝÔ´Ê×ÒªÌõ¼þ£º°²×°oracle client¡£°²×°ÍêÖ®ºóÌí¼Ó£¬µ«ÊÇ»¹±ØÐëÔÚ°²×°Ä¿Â¼ÏÂͨ³£ÊÇC:\oracle\ora90\network\ADMIN\tnsnames.oraÖÐÌí¼ÓÒ»¸öÁ¬½Ó£¬Èçϸñʽ£º DXS =
(DESCRIPTION =
......
1)½¨Á¢²Ù×÷ϵͳĿ¼e:\test£¬×¼±¸Êý¾ÝÎļþdept.txt²¢ÖÃÓÚe:\testÖ®ÏÂ
"10","ACCOUNTING","NEW
YORK"
"20","RESEARCH","DALLAS"
"30","SALES","CHICAGO"
"40","OPERATIONS","BOSTON"
2)´´ ......
HWMÊÇoracleÖÐblockÓÐûÓÐʹÓõķֽçÏߣ¬Ëü»áËæ×ÅÊý¾ÝµÄinsert¶øÉÏÉý£¬µ«Ëü²¢²»»áËæÊý¾ÝµÄdelete¶øÏ½µ£¬Òò´ËÈ«±íɨÃèµÄʱ¼ä²¢²»ÒòÊý¾ÝµÄdelete¶ø¼õÉÙ£¬Ïà·´¿ÉÄÜÓÉÓÚ¿éÇå³ý·´¶øÈ«±íɨÃèʱ¼äÔö¼Ó£¬¿ÉÒÔÓÃÏÂÃæ·½·¨µÄÈÎÒ»Ò»ÖÖÀ´½µµÍHWM£º
µÚÒ»ÖÖ£ºshrink
ÊÊÓÃÓÚ10gÒÔºóµÄ°æ±¾£¬Ç°ÌáÊÇÕâ¸ö±í£¬Ë÷Òý£¬ÎﻯÊÓͼ»òÎﻯÊÓͼlogËùÔ ......