程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> 關於Oracle數據庫 >> Windows下的Oracle導出腳本

Windows下的Oracle導出腳本

編輯:關於Oracle數據庫

       導出腳本內容:

      @echo off

      REM

      REM File name Daily.bat

      REM Batch Process

      Reload DB Backup

      REM

      REM Author Frank.Fan

      REM Modification History

      Created 2012-05-07

      REM Modified

      REM

      for /F "tokens=1-3 delims=/ " %%i in ('date /t') do @set FILENAMEDT=%%i%%j%%k

      #取系統當前日期:年月日(中文格式)、月日年(英文格式)

      for /F "tokens=1,2 delims=: " %%i in ('time /t') do @set FILENAMETM=%%i%%j

      #取系統當前時間:時分

      SET USERNAME=SYSTEM #oracle帳號

      SET USERPASSWD=123456 #oracle密碼

      SET SERVICENAME=QEWAY #oracle SID

      SET SCHEMASNAME=ISCOP #oracle SCHEMA帳號

      SET RARTOOL=C:Program FilesWinRAR #設定WINRAR路徑(各個機器不同)

      SET DBBACKUPPATH=D:DBBAK #設定被導出的文件路徑

      SET DBADIRECTORIES=DBBAK #oracle內設置的Directory目錄名

      SET DBBACKUPFILENAME=QEWAY_%FILENAMEDT%-%FILENAMETM%

      goto main

      :main

      ECHO Exporting schemas.......

      expdp %USERNAME%/%USERPASSWD%@%SERVICENAME% DUMPFILE=%DBADIRECTORIES%:%DBBACKUPFILENAME%.dmp schemas=%SCHEMASNAME% LOGFILE=%DBADIRECTORIES%:%DBBACKUPFILENAME%.log

      ECHO Done exporting schemas.

      ECHO =======================================================

      ECHO ...Done export

      if exist %DBBACKUPPATH%%DBBACKUPFILENAME%.RAR del %DBBACKUPPATH%%DBBACKUPFILENAME%.RAR

      "%RARTOOL%winrar.exe" a -ep %DBBACKUPPATH%%DBBACKUPFILENAME%.RAR %DBBACKUPPATH%%DBBACKUPFILENAME%.dmp

      del %DBBACKUPPATH%%DBBACKUPFILENAME%.dmp

      Echo ...Compression complete

      forfiles /p "%DBBACKUPPATH%" /m *.rar -d -30 /c "cmd /c del /f @path"

      #刪除30天之前的RAR文件

      REM -----------Send a mail to notification-----------

      start D:DBBAKBatch_notification_Daily.vbs #調用郵件通知VBS文件

      EXIT

      郵件通知VBS文件內容:

      NameSpace = "http://schemas.microsoft.com/cdo/configuration/"

      set Email = CreateObject("CDO.Message")

      Email.From = "[email protected]"

      Email.To = "[email protected]"

      Email.Subject = "Gongxtpt Batch Daily Task"

      Email.Textbody = "Gongxtpt Batch Daily Task was done!! Starting at 00:00AM"

      with Email.Configuration.Fields

      .Item(NameSpace&"sendusing") = 2

      .Item(NameSpace&"smtpserver") = "10.0.0.12"

      .Item(NameSpace&"smtpserverport") = 25

      .Item(NameSpace&"smtpauthenticate") = 0

      .Item(NameSpace&"sendusername") = ""

      .Item(NameSpace&"sendpassword") = ""

      .Update

      end with

      Email.Send

      Set Email=Nothing

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved