oracle导出数据库dmp文件

时间:2022-06-03 08:41:23

 导出数据库为dmp文件,按照当前导出时间设置文件名称

@ECHO OFF
ECHO 备份 SCOTT 用户的数据……
SET DBUserName
=scott
SET DBPassword
=1234
SET DBName
=orcl
SET DATE_STRING
=%DATE%
SET TIME_STRING
=%TIME%

IF
"%DATE_STRING:~3,1%"==" " (
SET DATE_STRING
=%DATE:~4,10%
) ELSE (
SET DATE_STRING
=%DATE:~0,10%
)

IF
"%TIME_STRING:~0,1%"==" " (
SET TIME_STRING
=0%TIME_STRING:~1,1%-%TIME_STRING:~3,2%-%TIME_STRING:~6,2%
) ELSE (
SET TIME_STRING
=%TIME_STRING:~0,2%-%TIME_STRING:~3,2%-%TIME_STRING:~6,2%
)

SET DMPFILENAME
=%DBUserName%_%DATE_STRING%_%TIME_STRING%.DMP
SET RARFILENAME
=%DBUserName%_%DATE_STRING%_%TIME_STRING%.RAR

EXP
%DBUserName%/%DBPassword%@%DBName% FILE=d:\backup\scott%date:~0,4%_%date:~5,2%_%date:~8,2%.dmp

RAR A
%RARFILENAME% %DMPFILENAME% -M5 -DF

ECHO
%TIMESTRING%
ECHO
========================================
ECHO 已导出DMP文件:
"%DMPFILENAME%"
REM PAUSE

 将该文件保存为.bat文件即可实现双击即导出。