oraclejob的遷移

因?yàn)镴OB的內(nèi)容是寫(xiě)死的,如果使用remap導(dǎo)入到別的用戶下,其log_user等還是原來(lái)的,再加上job的id是固定的,很可能和當(dāng)前庫(kù)有沖突,所以建議取出job的ddl。

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序定制開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了新化免費(fèi)建站歡迎大家使用!

 

dbms_metadata.get_ddl是不可以的。不行你們?cè)囋嚲椭懒恕?/p>

 

所以我寫(xiě)了個(gè)plsql

set serveroutput on size 100000
set termout on
set feedback off
clear screen
spool /opt/soft/bak/make_jobs.sql
prompt -- exporting jobs
begin
<< export_jobs >>
declare 
  subtype   job_type       is  user_jobs.JOB%type    ;
  subtype   max_text_type  is  varchar2( 8191 char ) ;
  type      job_tab_type   is  table of   job_type        index by pls_integer ;
  type      sql_tab_type   is  table of   max_text_type   index by pls_integer ;
      
  job_tab     job_tab_type  ;
  sql_tab     sql_tab_type  ;
  job         pls_integer   ;
  what        pls_integer   ;
  next_date   pls_integer   ;
  interval    pls_integer   ;
  no_parse    pls_integer   ;
  procedure 
        get_jobs
  is
  begin
        select j.JOB
          bulk collect
          into job_tab
          from user_jobs j
         order by 1
        ;
  end   get_jobs
  ;
  
  procedure 
        format( x pls_integer )
  is 
        sqlx     max_text_type  :=  null ;
  begin 
                sqlx := 'begin'                                                     || chr(10);
        job          :=   instr( sql_tab(x), '(job=>' ) ;
        sqlx := sqlx ||  substr( sql_tab(x), 1, job-1 )                             || chr(10) ;
        what         :=   instr( sql_tab(x),',what=>' ) ;
        sqlx := sqlx ||  substr( sql_tab(x), job, what-job )                        || chr(10) ;
        next_date    :=   instr( sql_tab(x),',next_date=>' ) ;
        sqlx := sqlx ||  substr( sql_tab(x), what, next_date-what )                 || chr(10) ;
        interval     :=   instr( sql_tab(x),',interval=>' ) ;
    --  sqlx := sqlx ||  substr( sql_tab(x), next_date, interval-next_date )        || chr(10) ;
        sqlx := sqlx ||  q'|,next_date=>'01-JAN-3000'|'                             || chr(10) ;
        no_parse     :=   instr( sql_tab(x),',no_parse=>' ) ;
        sqlx := sqlx ||  substr( sql_tab(x), interval, no_parse-interval )          || chr(10) ;
        sqlx := sqlx ||  ',no_parse=>TRUE'                || chr(10) || ');' || chr(10) ;
        sqlx := sqlx ||  'commit;'                        || chr(10)         || chr(10) ;
        sqlx := sqlx ||  'end;'                           || chr(10) || '/'  || chr(10) ;
        
        sql_tab(x)   :=  sqlx;
  end   format
  ;          
  
begin
      get_jobs;
      if    
            job_tab.count > 0 
      then
            for   
                  i   in  1 .. job_tab.count
            loop
                  sql_tab(i) := ' ';
                  sys.dbms_job.user_export
                  (  job    =>  job_tab(i)
                   , mycall =>  sql_tab(i)
                  );
                  format(i) ;
                  dbms_output.put_line( sql_tab(i) ) ;
            end   loop
            ;
      else
            dbms_output.put_line( '-- Nothing to do.' ) ; 
      end   if
      ;
end export_jobs
;
end;
/
spool off

 

然后呢,用這個(gè)得到輸出重建job。如果你遇到

ORA-00001: unique constraint (SYS.I_JOB_JOB) violated

就說(shuō)明job列重復(fù)了,這時(shí)候你有兩種方法,一個(gè)是重置job,改個(gè)沒(méi)人用的。

另一種就是刪了現(xiàn)在的job重建。

刪除語(yǔ)法是

exec dbms_job.remove(25);

 如果刪除時(shí)遇到如下:

ORA-23421: job number 387 is not a job in the job queue

很有可能是因?yàn)槟愕挠脩舨皇莏ob的owner。

select job,log_user,priv_user,schema from dba_jobs where job=25;

然后切換過(guò)去再刪除,同理,建立也必須使用當(dāng)前用戶。

標(biāo)題名稱:oraclejob的遷移
文章分享:http://bm7419.com/article12/jdcjdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、Google做網(wǎng)站、服務(wù)器托管網(wǎng)站營(yíng)銷(xiāo)、網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)