Oracle 10g schedule jobµÄ³£ÓòÙ×÷
OracleÊý¾Ý¿â10g schedule jobµÄ³£ÓòÙ×÷:
-- job ȨÏÞ
grant create job to somebody;
-- job ´´½¨
begin
dbms_scheduler.create_job (
job_name => 'AGENT_LIQUIDATION_JOB',
job_type => 'STORED_PROCEDURE',
job_action => 'AGENT_LIQUIDATION.LIQUIDATION', --´æ´¢¹ý³ÌÃû
start_date => sysdate,
repeat_interval => 'FREQ=MONTHLY; INTERVAL=1; BYMONTHDAY=1;BYHOUR=1;BYMINUTE=0;BYSECOND=0', -- °´Ô£¬¼ä¸ôΪ1¸ö(ÔÂ),ÿÔÂ1ºÅ,Á賿1µã
comments => 'Ö´ÐдúÀíÉÌÇå·Ö³ÌÐò'
);
end;
/
-- job Ö´ÐÐʱ¼ä²âÊÔ
DECLARE
start_date date;
return_date_after date;
next_run_date date;
BEGIN
start_date := sysdate;--to_timestamp_tz('10-OCT-2004 10:00:00','DD-MM-YYYY HH24:MI:SS');
return_date_after := start_date;
FOR i IN 1..10 LOOP
DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING('FREQ=MONTHLY; INTERVAL=1; BYMONTHDAY=1;BYHOUR=1;BYMINUTE=0;BYSECOND=0',start_date, return_date_after, next_run_date);
DBMS_OUTPUT.PUT_LINE('next_run_date: ' || to_char(next_run_date,'yyyy-mm-dd HH24:MI:SS'));
return_date_after := next_run_date;
END LOOP;
END;
/
-- job ²éѯ
select owner, job_name, state from dba_scheduler_jobs;
select job_name, state from user_scheduler_jobs;
-- job ÆôÓÃ
begin
dbms_scheduler.enable('BACKUP_JOB');
end;
/
-- job ÔËÐÐ
begin
dbms_scheduler.run_job('COLA_JOB',TRUE); -- true´ú±íͬ²½Ö´ÐÐ
end;
/
-- job Í£Ö¹(²»Ì«ºÃÓÃ)
begin
dbms_scheduler.stop_job(job_name => 'COLA_JOB',force => TRUE);
end;
/
-- job ɾ³ý(¶ÔÍ£jobÀ´ËµºÃÓÃ)
begin
dbms_scheduler.drop_job(job_name => 'COLA_JOB',force => TRUE);)
end;
/
Ïà¹ØÎĵµ£º
1£©wwµÄË㷨ΪÿÄê1ÔÂ1ÈÕΪµÚÒ»ÖÜ¿ªÊ¼£¬date+6ΪÿһÖܽáβ
¡¡¡¡ÀýÈç20050101ΪµÚÒ»ÖܵĵÚÒ»Ì죬¶øµÚÒ»ÖܵÄ×îºóÒ»ÌìΪ20050101+6=20050107
¡¡¡¡¹«Ê½ ÿÖܵÚÒ»Ìì £ºdate + ÖÜ * 7 - 7
¡¡¡¡Ã¿ÖÜ×îºóÒ»Ì죺date + ÖÜ * 7 - 1
2£©iwµÄË㷨ΪÐÇÆÚÒ»ÖÁÐÇÆÚÈÕËãÒ»ÖÜ£¬ÇÒÿÄêµÄµÚÒ»¸öÐÇÆÚһΪµÚÒ»ÖÜ£¬
¡¡¡¡ ÀýÈç20050101Î ......
Oracle
1£¬shutdownÖ®ºó£¬ÈçºÎÆô¶¯Êý¾Ý¿âʵÀý£¿
ͨ¹ýCMDÃüÁî·û sqlplus "sys/password as
sysdba"£¬»áÁ¬µ½Ò»¸ö¿ÕÏÐʵÀý£¬ÕâÑù¿ÉÔÙÓÃstartupÃüÁî¡£
2£¬×°ÁËÊý¾Ý¿âÖ®ºó£¬ÓÃÁËshutdown£¬ºóÓÃÁËstartupµÈÆô¶¯Ö®ºó£¬¿ÉÓÃsql
plusºÍÍøÒ³·½Ê½Á¬oracle¡£µ«ÓÃjdbcÁ¬½Ó³ö´í£¿
ÊǼàÌýÆ÷ûÆô¶¯£ºD:\oracle\product\10.1.0\Db_1\ ......
select * from test where rownum <=10 ÏÂÃæÊǹØÓÚrownumµÄ½éÉÜ ================================ RownumºÍrow_number() over()µÄʹÓà ROWNUMÊÇOracle´Ó8¿ªÊ¼ÌṩµÄÒ»¸öαÁУ¬ÊÇ°ÑSQL³öÀ´µÄ½á¹û½øÐбàºÅ£¬Ê¼ÖÕ´Ó1¿ªÊ¼£¬³£¼ûµÄÓÃ;¾ÍÊÇÓÃÀ´·ÖÒ³Êä³ö. ±ÈÈç SELECT * from torderdetail a WHERE ROWNUM <= 10 ÕâÌõÓï¾ä¾ ......
´ÓAIX ½Ç¶È£¬ÎÒÃÇ¿ÉÒÔÔÚÏÂÃæÈý¸ö½Ç¶ÈºâÁ¿ÄÚ´æʹÓõĺÏÀíÐÔ
1>¼õÉÙÒ³Ãæ½»»»²Ù×÷
µ±²Ù×÷ϵͳÐèÒª¸ü¶àÄÚ´æÒ³ÒÔÖ§³ÖÆäËûÓ¦ÓÃÔËÐÐʱ£¬²Ù×÷ϵͳ½«ÒÀ¾ÝijÖÖËã·¨£¨LRUËã·¨£©°Ñµ±Ç°×¤ÁôÔÚÄÚ´æÖеÄijЩ
Êý¾ÝÒ³"Page Out"£¬Ò²¾ÍÊÇ°ÑÄÚ´æÖеÄÊý¾ÝÒ³´ÓÄÚ´æ¶ÎתÒƵ½ÎïÀí´ÅÅÌ¡£ÏÔÈ»£¬ÕâÖÖÀàÐ͵IJÙ×÷»áÓ°ÏìÕû¸öϵͳµÄÔËÐÐÐÔÄÜ¡£
¶ÔÓÚ ......
ÕâƪÂÛ̳ÎÄÕ£¨ÈüµÏÍø¼¼ÊõÉçÇø£©Õë¶ÔDBMS_SCHEDULERµÄʹÓ÷½·¨½øÐÐÁËÏ꾡µÄ½éÉÜ£¬¸ü¶àÄÚÈÝÇë²Î¿¼ÏÂÎÄ£º
DBMS_SCHEDULERÊÇOracle 10GÖÐÐÂÔöµÄÒ»¸ö°ü£¬ÓëÀÏ°æ±¾µÄdbms_job°üÏà±È£¬dbms_schedulerÓкܶàÐÂÌØÐÔ£¬ÎÒ½«Í¨¹ýһϵÁеÄÎÄÕÂÀ´½éÉÜÒ»ÏÂÈçºÎʹÓÃÕâ¸ö°ü.
1. ´´½¨job
job ......