oracle导出数据库dmp文件

时间:2024-08-15 17:04:50

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

@ECHO OFF
ECHO 备份 SCOTT 用户的数据……
SET DBUserName=scott
SET DBPassword=
SET DBName=orcl
SET DATE_STRING=%DATE%
SET TIME_STRING=%TIME% IF "%DATE_STRING:~3,1%"==" " (
SET DATE_STRING=%DATE:~,%
) ELSE (
SET DATE_STRING=%DATE:~,%
) IF "%TIME_STRING:~0,1%"==" " (
SET TIME_STRING=%TIME_STRING:~,%-%TIME_STRING:~,%-%TIME_STRING:~,%
) ELSE (
SET TIME_STRING=%TIME_STRING:~,%-%TIME_STRING:~,%-%TIME_STRING:~,%
) 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:~,%_%date:~,%_%date:~,%.dmp RAR A %RARFILENAME% %DMPFILENAME% -M5 -DF ECHO %TIMESTRING%
ECHO ========================================
ECHO 已导出DMP文件:"%DMPFILENAME%"
REM PAUSE

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