È«ÃæѧϰORACLE SchedulerÌØÐÔ(3)ʹÓÃPrograms
¶þ¡¢Ê¹ÓÃPrograms
¡¡¡¡ÔÚÂÛ̳ÖÐż¶û¼û¹ýÓÐÈËÌÖÂÛÈçºÎÔÚORACLEÖÐÖ´ÐвÙ×÷ϵͳÃüÁ»òÊÇORACLEÊý¾Ý¿âÍâµÄÓ¦Óá£Ó¦¸Ã˵ÔÚ9i¼°Ö®Ç°µÄ°æ±¾ÖУ¬ËäȻ˵²¢·ÇÍêÈ«ÎÞ·¨ÊµÏÖ£¨Æäʵ»¹ÊÇÓжàÖÖ·½Ê½Äܹ»±äÏàʵÏֵģ©£¬²»¹ý¸´ÔÓµÄʵÏÖ·½Ê½ÈÃDBAʹ¾¢ÁËÁ¦£¬ÉË͸ÁËÐÄ£¬·Ñ¾¢ÁËʶù¡£
¡¡¡¡½øÈë10g°æ±¾Ö®ºó£¬¾ÍÍêÈ«²»±ØÈç´Ë·ÑÉñ£¬ÒòΪÓÐÁËDBMS_SCHEDULER£¬ÒòΪÓÐÁËPROGRAM¡£
2.1 ´´½¨Programs
¡¡¡¡Scheduler ÖеÄProgram¶ÔÏó²¢²»Êdz£¹æÒâÒåÉϵÄ"³ÌÐò"»ò"Ó¦ÓÃ"£¬¶ø¾ÍÊÇÒ»¸ö"¶ÔÏó"£¬ÓÉDBA¶¨ÒåµÄ£¬¾ßÓÐÖ´ÐÐijÏÄܵÄÌØÊâ¶ÔÏó¡£ProgramÖÐʵ¼ÊÖ´ÐеIJÙ×÷¿ÉÒÔ·ÖΪÏÂÁÐÈýÖÖÀàÐÍ£º
PL/SQL BLOCK £º±ê×¼µÄpl/sql´úÂë¿é£»
STORED PROCEDURE £º±àÒëºÃµÄPL/SQL´æ´¢¹ý³Ì£¬»òÕßJava´æ´¢¹ý³Ì£¬ÒÔ¼°ÍⲿµÄc×Ó³ÌÐò£»
EXECUTEABLE £ºORACLEÊý¾Ý¿âÖ®ÍâµÄÓ¦Ó㬱ÈÈç²Ù×÷ϵͳÃüÁîµÈµÈ¡£
¡¡¡¡´´½¨ProgramsʹÓÃDBMS_SCHEDULER.CREATE_PROGRAM¹ý³Ì£¬¸Ã¹ý³ÌÖ§³ÖµÄ²ÎÊýÈçÏ£º
JSSWEB> desc dbms_scheduler.create_program;
Parameter Type Mode Default?
------------------- -------------- ---- --------
PROGRAM_NAME VARCHAR2 IN
PROGRAM_TYPE VARCHAR2 IN
PROGRAM_ACTION VARCHAR2 IN
NUMBER_OF_ARGUMENTS BINARY_INTEGER IN Y
ENABLED BOOLEAN IN Y
OMMENTS VARCHAR2 IN Y
¡¡¡¡ÈçÉÏËùʾ£¬Ç°ÈýÏîΪ±ØÑ¡²ÎÊý£¬¸÷²ÎÊýʵ¼Ê´ú±íµÄÒâÒåÈçÏ£º
PROGRAM_NAME £ºÖ¸¶¨Ò»¸öprogramÃû³Æ£»
PROGRAM_TYPE £ºProgramµÄÀàÐÍ£¬ÈçÇ°ÎÄÖÐËùÊö£¬ProgramÖ§³ÖÈýÖÖÀàÐÍ£»
PROGRAM_ACTION £ºÊµ¼ÊÖ´ÐеIJÙ×÷£¬Ó¦ÓëÇ°ÃæPROGRAM_TYPE²ÎÊý¹ØÁªÊ¹ÓᣱÈÈç˵ǰÃæÖ¸¶¨ÁËPROGRAM_TYPEΪ"PLSQL_BLOCK"£¬ÄÇô´Ë´¦ÒªÖ´ÐеÄaction¾ÍÓ¦µ±ÊÇÒ»¶Î±ê×¼µÄpl/sql´úÂë¡£Èç¹ûÇ°ÃæÖ¸¶¨PROGRAM_TYPEΪ"STORED_PROCEDURE"£¬ÄÇô´Ë´¦ÒªÖ´ÐеÄaction¾ÍÓ¦µ±ÊÇORACLEÖж¨ÒåºÃµÄ´æ´¢¹ý³Ì(º¬Java´æ´¢¹ý³Ì)£¬Èç¹ûÇ°ÃæÖ¸¶¨PROGRAM_TYPEΪ"EXECUTABLE"£¬ÄÇô´Ë´¦¾ÍÓ¦¸ÃÖ¸¶¨ÍⲿÃüÁîµÄÃüÁîÐÐÐÅÏ¢(º¬Â·¾¶ÐÅÏ¢)£»
NUMBER_OF_ARGUMENTS £ºÖ¸¶¨Ö§³ÖµÄ²ÎÊý¸öÊý£¬Ä¬ÈÏֵΪ0¼´Ã»ÓвÎÊý¡£Ã¿¸öprogram×î¶àÄܹ»Ö§³Ö255¸ö²ÎÊý£¬×¢ÒâÈç¹ûPROGRAM_TYPEÉèÖÃΪPLSQL_BLOCK£¬ÄÇô±¾²ÎÊý×Ô¶¯ºöÂÔ£»
ENABLED £ºÖ¸¶¨ÊÇ·ñ½«´´½¨µÄprogramÖÃΪÓÐЧ״̬£¬Ä¬ÈÏÇé¿öÏÂΪf
Ïà¹ØÎĵµ£º
1£©wwµÄË㷨ΪÿÄê1ÔÂ1ÈÕΪµÚÒ»ÖÜ¿ªÊ¼£¬date+6ΪÿһÖܽáβ
¡¡¡¡ÀýÈç20050101ΪµÚÒ»ÖܵĵÚÒ»Ì죬¶øµÚÒ»ÖܵÄ×îºóÒ»ÌìΪ20050101+6=20050107
¡¡¡¡¹«Ê½ ÿÖܵÚÒ»Ìì £ºdate + ÖÜ * 7 - 7
¡¡¡¡Ã¿ÖÜ×îºóÒ»Ì죺date + ÖÜ * 7 - 1
2£©iwµÄË㷨ΪÐÇÆÚÒ»ÖÁÐÇÆÚÈÕËãÒ»ÖÜ£¬ÇÒÿÄêµÄµÚÒ»¸öÐÇÆÚһΪµÚÒ»ÖÜ£¬
¡¡¡¡ ÀýÈç20050101Î ......
´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´æ´¢¹ý³Ì£¬ËüÔÚ²åÈ룬ɾ³ý»òÐÞ¸ÄÌض¨±íÖеÄÊý¾Ýʱ´¥·¢Ö´ÐУ¬Ëü±ÈÊý¾Ý¿â±¾Éí±ê×¼µÄ¹¦ÄÜÓиü¾«Ï¸ºÍ¸ü¸´ÔÓµÄÊý¾Ý¿ØÖÆÄÜÁ¦¡£Êý¾Ý¿â´¥·¢Æ÷ÓÐÒÔϵÄ×÷Óãº
¡¡¡¡* °²È«ÐÔ¡£¿ÉÒÔ»ùÓÚÊý¾Ý¿âµÄֵʹÓû§¾ßÓвÙ×÷Êý¾Ý¿âµÄijÖÖȨÀû¡£
¡¡¡¡# ¿ÉÒÔ»ùÓÚʱ¼äÏÞÖÆÓû§µÄ²Ù×÷£¬ÀýÈç²»ÔÊÐíÏ°àºóºÍ½Ú¼ÙÈÕÐÞ¸ÄÊý¾Ý¿âÊý¾Ý¡£ ......
ÒÔsystemµÇ¼½øÈ¥Ö®ºó£¬Ö´ÐÐÏÂÃæµÄÃüÁ
SQL> alter user scott account unlock; £¨Íê³É½âËøµÄ²Ù×÷£©
Óû§ÒѸü¸Ä¡£
SQL> alter user scott identified by tiger; £¨ÖØиøscottÕâ¸öÓû§É趨ÃÜÂ룩
Óû§ÒѸü¸Ä¡£
SQL> conn scott/tiger
ÒÑÁ¬½Ó¡£ ......
·½·¨Ò»£º×î¼òµ¥µÄ·½·¨£¨Ð轨¿â£©
±¸·Ý£º
Ö±½Ó¿½±´oracleĿ¼ÏµÄadmin¡¢oradataÁ½¸öÎļþ¼Ð£¬ora92Ŀ¼ÏÂdatabase£¬µ½ÆäËû´æ´¢ÊµÏÖ±¸·Ý¡£
»Ö¸´£º
1.´´½¨Ò»¸öºÍÔÀ´Ò»ÑùµÄÊý¾Ý¿â¡£(°²×°Â·¾¶ºÍÊý¾Ý¿âÃû±ØÐëºÍÔÀ´Ò»ÖÂ)
2.ÓùÜÀíÔ±Á¬ÈëÊý¾Ý¿âºóÍ£Ö¹Êý¾Ý¿â¡£
3.°Ñ°²×°Ä¿Â¼ÏµÄadminºÍoradata¸´ÖƹýÈ¥¸²¸Ç£¨Èç¹û´æÔÚ ......
ÕâƪÂÛ̳ÎÄÕ£¨ÈüµÏÍø¼¼ÊõÉçÇø£©Õë¶ÔDBMS_SCHEDULERµÄʹÓ÷½·¨½øÐÐÁËÏ꾡µÄ½éÉÜ£¬¸ü¶àÄÚÈÝÇë²Î¿¼ÏÂÎÄ£º
DBMS_SCHEDULERÊÇOracle 10GÖÐÐÂÔöµÄÒ»¸ö°ü£¬ÓëÀÏ°æ±¾µÄdbms_job°üÏà±È£¬dbms_schedulerÓкܶàÐÂÌØÐÔ£¬ÎÒ½«Í¨¹ýһϵÁеÄÎÄÕÂÀ´½éÉÜÒ»ÏÂÈçºÎʹÓÃÕâ¸ö°ü.
1. ´´½¨job
job ......