text ORCL - 创造就业

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text ORCL - 创造就业相关的知识,希望对你有一定的参考价值。

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name             => 'gather_schema',
   job_type             => 'PLSQL_BLOCK',
   job_action           => 'BEGIN dbms_stats.gather_schema_stats(ownname=>''DBA_FID'', estimate_percent=> 10, method_opt=> ''for all columns size auto'',degree=> 1); END;',
   start_date           =>  SYSTIMESTAMP,
   repeat_interval      => 'FREQ=DAILY;byhour=03;byminute=0;', 
   end_date             =>  NULL,
   enabled              =>  TRUE,
   comments             => 'Gather schema DBA_FID tous les jours a 3h');
END;
/

# Attention, il s'agit de 2 simple quote et non une double quote autour de DBA_FID

CREATE OR REPLACE PROCEDURE SYS.REBUILD_TABLE_INDEX
AS
SQL_STR VARCHAR2(1000);
BEGIN

    FOR CUROSR_INDEX IN (SELECT OWNER,INDEX_NAME from dba_indexes
        WHERE OWNER='DBA_FID'
        ORDER BY INDEX_NAME ) LOOP

        BEGIN
        SQL_STR:='ALTER INDEX '||CUROSR_INDEX.OWNER||'.'||CUROSR_INDEX.INDEX_NAME ||' REBUILD NOLOGGING';        
        EXECUTE IMMEDIATE SQL_STR;
        DBMS_OUTPUT.PUT_LINE('SUCCESS : '|| CUROSR_INDEX.OWNER||'.'||CUROSR_INDEX.INDEX_NAME);
        EXCEPTION WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('ERROR : '||CUROSR_INDEX.OWNER||'.'||CUROSR_INDEX.INDEX_NAME||':'||SQLERRM);
        END;
 
END LOOP;
END;
/
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name             => 'REBUILD_INDEX',
   job_type             => 'STORED_PROCEDURE',
   job_action           => 'REBUILD_TABLE_INDEX',
   start_date           =>  SYSTIMESTAMP,
   repeat_interval      => 'FREQ=DAILY;byday=MON;byhour=04;byminute=0;', 
   end_date             =>  NULL,
   enabled              =>  TRUE,
   comments             => 'Rebuild index DBA_FID tous les lundi a 4h');
END;
/


BEGIN
  dbms_scheduler.drop_job(job_name => 'REBUILD_INDEX');
END;
/


executer le job manuellement :
execute dbms_scheduler.run_job('REBUILD_INDEX');
SELECT OPERATION, JOB_NAME, STATUS FROM DBA_OPTSTAT_OPERATIONS ORDER BY START_TIME;

SELECT job_name, log_date, status, actual_start_date, run_duration, cpu_used FROM dba_scheduler_job_run_details where job_name like '%GATHER%';

以上是关于text ORCL - 创造就业的主要内容,如果未能解决你的问题,请参考以下文章

text ORCL - 索引

text ORCL - PGA

text ORCL - 监听器日志

text ORCL - Afficher un datafile

text ORCL - 闪回查询

text ORCL - DéplacerunDatafile