Because of the usual database backup and restore operations, To improve efficiency and save time, you have the following batch process. This is written for Oracle, can be used on different computers, because it will automatically read the current computer environment variables, so as to obtain the Oracle installation path, the only point is that the program running in the process will produce an intermediate text file, but this is not a major problem , the resulting text file will be automatically deleted after the backup or restore is completed, and the code is as follows:
@echo off&setlocal enabledelayedexpansion
Color 0a
: Start
for/f "tokens=2 delims=="%%a in (' Path ') does (
Set "Str=%%a"
Set STR=!STR: =+!
For%%i in (!str!) do (
Set "Var=%%i"
Set var=!var:+=!
Echo!var!>>change.txt
for/f "delims="%%i in (' findstr "Oracle" Change.txt ") do set var=%%i
)
)
Set/p choice=1. Back up 2. Restore 3. Press any key to exit:
If%choice%==1 goto EXP
If%choice%==2 goto IMP
: Exp
del/q Change.txt
set/p file= Please enter the filename of the spare parts database:
set/p path= Please enter the stored path (remember the colon:):
"%var%" \exp.exe smhr/smhr file=%path%\%file% full=n
set/p choice=1. Continue 2. Press any key to exit:
If%choice%==1 goto start
: Imp
del/q Change.txt
set/p file= Please drag the database file you want to import into the body of the window:
"%var%" \imp.exe smhr/smhr file=%file% full=y
set/p choice=1. Continue 2. Press any key to exit:
If%choice%==1 goto start