麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 數據庫 > Oracle > 正文

Windows下編寫批處理腳本來啟動和重置Oracle數據庫

2024-08-29 13:58:55
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了Windows下編寫cmd腳本來對Oracle數據庫執行啟動和重置的方法,只需在bat文件中保存cmd shell之后就可以雙擊使用,簡單粗暴,需要的朋友可以參考下
 

cmd啟動Oracle數據庫
新建一個bat文件,復制內容進去,雙擊即可啟動.

@echo off net start OracleXETNSListener 2>nul net start OracleServiceXE 2>nul @oradim -startup -sid XE -starttype inst > nul 2>&1 

 

Oracle重置數據庫命令
新建bat文件,復制以下內容,然后執行。

@echo off REM REM The script assumes that user can connect using "/ as sysdba" REM REM ================= REM Restore procedure REM ================= REM REM If Installed Oracle home is also lost and oracle binaries were REM re-installed or the Oracle is installed to new oracle home location REM compared to backup time, then user will be prompted to enter Flash REM Recovery Area location. REM REM For database in NoArchiveLog mode, database is restored to last offline REM backup time/scn; REM For database in Archive log mode, database is restored from last backup REM and a complete recovery is attempted. If complete recovery fails, REM user can open the database with resetlogs option provided the files REM are not recovery fuzzy. REM REM The restore log is saved in ?/DATABASE/OXE_RESTORE.LOG REM  setlocal  set /p inp="This operation will shut down and restore the database. Are you sure [Y/N]?" :checkinp if /i "%inp%" == "Y" goto :confirmedyes if /i "%inp%" == "n" exit :Askagain set /p inp= goto :checkinp  :confirmedyes  echo Restore in progress...  echo db_name=xe >%temp%/rman_dummy.ora echo sga_target=270M >>%temp%/rman_dummy.ora   net start oracleserviceXe  REM Startup database in nomount mode using RMAN... @( echo set echo on^; echo startup nomount pfile=%temp%/rman_dummy.ora force^; ) > %temp%/restore_rman0.dat rman target / @%temp%/restore_rman0.dat if not %errorlevel% == 0 set Errorstr= RMAN Error - could not startup dummy instance & goto :restorefailederr  @( echo connect / as sysdba^; echo set head off echo set echo off echo set linesize 515 echo variable var varchar2^(512^)^; echo execute :var := sys.dbms_backup_restore.normalizefilename^(^'SPFILE2INIT^'^)^; echo spool %temp%/spfile2init.log echo select sys.dbms_backup_restore.normalizefilename^(^'SPFILE2INIT.ORA^'^) spfile2init from dual^; echo exit^; ) > %temp%/spfile2init.sql sqlplus /nolog @%temp%/spfile2init.sql >nul FOR /F %%i in (%temp%/spfile2init.log) do set SPFILE2INIT=%%i  @( echo connect / as sysdba;  echo set head off  echo set echo off  echo set linesize 515  echo variable var varchar2^(512^)^;  echo execute :var := sys.dbms_backup_restore.normalizefilename^(^'FRA_LOC^'^)^;  echo spool %temp%/restore_rmanlog.log  echo select sys.dbms_backup_restore.normalizefilename^(^'OXE_RESTORE.LOG^'^) RESTORE_RMANLOG from dual^;  echo exit^; ) > %temp%/restore_rmanlog.sql sqlplus /nolog @%temp%/restore_rmanlog.sql >nul FOR /F %%i in (%temp%/restore_rmanlog.log) do set RESTORE_RMANLOG=%%i  if not exist ^"%SPFILE2INIT%^" goto get_rcvarea_loc @(  echo set echo on^;  echo shutdown immediate^;  echo startup nomount pfile=^"%SPFILE2INIT%^"^;  echo restore ^(spfile from autobackup^) ^(controlfile from autobackup^)^;  echo startup mount force^;  echo configure controlfile autobackup off^;  echo restore database^; ) > %temp%/restore_rman1.dat rman target / @%temp%/restore_rman1.dat trace "%RESTORE_RMANLOG%" if not %errorlevel% == 0 set Errorstr= RMAN Error - See log for error & goto :restorefailederr goto restored_files  :get_rcvarea_loc set /p rcvarea_loc="Enter the flash recovery area location:" @(  echo set echo on^;  echo restore ^(spfile from autobackup db_recovery_file_dest=^'%rcvarea_loc%^'^)^;  echo startup nomount force^;  echo restore ^(controlfile from autobackup^)^;  echo alter database mount^;  echo configure controlfile autobackup off^;  echo restore database^; ) > %temp%/restore_rman1.dat rman target / @%temp%/restore_rman1.dat trace "%RESTORE_RMANLOG%" if not %errorlevel% == 0 set Errorstr= RMAN Error - See log for error & goto :restorefailederr goto restored_files  :restored_files @(  echo connect / as sysdba^;  echo declare cursor n1 is select name from v$tempfile^;  echo begin  echo for a in n1  echo loop  echo begin  echo sys.dbms_backup_restore.deletefile^(a.name^)^;  echo exception  echo when others then  echo null^;  echo end^;  echo end loop^;  echo end^;  echo /  echo exit^;  echo / ) > %temp%/deltfile.sql sqlplus /nolog @%temp%/deltfile.sql >nul @(  echo connect / as sysdba^;  echo set head off  echo set echo off  echo spool %temp%/logmode.log  echo select log_mode from v$database^;  echo exit^; ) > %temp%/logmode.sql sqlplus /nolog @%temp%/logmode.sql >nul FOR /F %%i in (%temp%/logmode.log) do set LOGMODE=%%i  if "%LOGMODE%" == "NOARCHIVELOG" goto process_noarchivelog if "%LOGMODE%" == "ARCHIVELOG" goto process_archivelog set Errorstr= Unknown log mode : %LOGMODE% goto :restorefailederr  :process_noarchivelog @(  echo set echo on^;  echo alter database open resetlogs; ) > %temp%/restore_rman2.dat rman target / @%temp%/restore_rman2.dat trace "%RESTORE_RMANLOG%" append if not %errorlevel% == 0 set Errorstr= RMAN Error - See log for details & goto :restorefailederr goto :restoresucess  :process_archivelog @(  echo set echo on^;  echo recover database^;  echo alter database open resetlogs; ) > %temp%/restore_rman2.dat rman target / @%temp%/restore_rman2.dat trace "%RESTORE_RMANLOG%" append if not %errorlevel% == 0 set Errorstr= RMAN Error - See log for details & goto :restorefailederr goto :restoresucess  :restoresucess echo Restore of the database succeeded. echo Log file is at %RESTORE_RMANLOG%. pause Press any key to exit exit goto :EOF  :restorefailederr echo ==================== ERROR ============================= echo Restore of the database failed. echo %Errorstr%. echo Log file is at %RESTORE_RMANLOG%. echo ==================== ERROR ============================= pause Press any key to exit exit goto :EOF 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黄色片观看 | 女人解衣喂奶电影 | 久久久一区二区三区视频 | 国产片91 | 免费性爱视频 | 91九色视频 | 97中文字幕在线观看 | 久久福利精品 | 久久综合久久精品 | 国产午夜免费 | 日韩中字幕 | 中文字幕国 | 久草干 | 亚洲aⅴ免费在线观看 | 久久久在线免费观看 | 黄色网欧美 | xnxx 美女19| 在线看小早川怜子av | 香蕉成人在线视频 | 国产一级在线免费观看 | 国产成人综合在线观看 | 在线看免费观看av | 欧美亚洲国产一区 | 欧美日韩大片在线观看 | 国产羞羞视频在线免费观看 | 高潮激情aaaaa免费看 | 精品国产乱码一区二区 | 天天夜夜草 | 久久精品国产久精国产 | 精品一区二区在线观看视频 | 九九热免费精品 | a集毛片 | 91美女视频在线 | 一区二区久久精品66国产精品 | 国产欧美精品一区二区三区四区 | 色人阁导航 | 极品大长腿啪啪高潮露脸 | 久久久精品综合 | 久久精品视频在线 | 国产91极品 | 羞羞视频一区二区 |