如何用plsql备份用户数据库

如题所述

建议采用数据泵来导出 exp (远端) /expdp (server 端)比较好吧,

在DOS 模式

exp sys/passwd file=filename log=logfile_name full=y 


如果是导出 储存过程的话以下仅供参考:

create or replace PROCEDURE PROC_PROCEDURE_BCK
   
   IS
  File_Handle Utl_File.File_Type;
  Stor_Text   Varchar2(4000);
  n           Number;
  i           Number;
Begin
  
  
 For a In (Select object_Name As Name From User_Objects where Object_type= Upper('procedure') ) 
 Loop
 File_Handle := UTL_FILE.FOPEN('BCCCGC', a.name || '.prc', 'W'); //BCCCGC 为提前定义好的路径
 Select Max(Line) Into n From All_Source Where Owner = Upper( 'TSD' ) And Name = a.name and TYPE='PROCEDURE';
 DBMS_OUTPUT.PUT_LINE(a.NAME);
  While i <= n Loop 
    
    Select Text Into Stor_Text From All_Source Where Owner = Upper( 'TSD'  ) And Name = a.name And Line = i and TYPE='PROCEDURE';
    i := i + 1;
    
  Utl_File.Put_Line(File_Handle, Stor_Text);
  End Loop;
i := 1;
  Utl_File.Fclose(File_Handle);
  
  Commit;
  End Loop ;
End;

温馨提示:答案为网友推荐,仅供参考
相似回答