婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Windows下編寫批處理腳本來啟動和重置Oracle數據庫

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

熱門標簽:開發外呼系統 圖吧網站地圖標注 地圖標注養老院 哪個400外呼系統好 哈爾濱電話機器人銷售招聘 山東crm外呼系統軟件 百度地圖標注途經點 慧營銷crm外呼系統丹丹 愛客外呼系統怎么樣

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 

您可能感興趣的文章:
  • BAT 批處理腳本教程(詳細篇腳本之家補充)
  • Windows server利用批處理腳本判斷端口啟動tomcat的方法
  • Windows下bat批處理腳本使用telnet批量檢測遠程端口小記
  • 實現android應用程序自動化測試的批處理腳本
  • ip地址切換批處理腳本分享
  • 批量安裝windows補丁的批處理腳本
  • QQ多帳號自動登錄批處理腳本
  • 本地連接禁用/啟用批處理腳本
  • DOS批處理腳本語言簡介與詳細說明
  • Windows注冊表中修改UAC(用戶賬號控制)及批處理腳本

標簽:開封 和田 甘肅 青島 承德 固原 武漢 周口

巨人網絡通訊聲明:本文標題《Windows下編寫批處理腳本來啟動和重置Oracle數據庫》,本文關鍵詞  Windows,下,編寫,批處理,腳,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Windows下編寫批處理腳本來啟動和重置Oracle數據庫》相關的同類信息!
  • 本頁收集關于Windows下編寫批處理腳本來啟動和重置Oracle數據庫的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 宁晋县| 迭部县| 精河县| 六盘水市| 馆陶县| 宁德市| 克什克腾旗| 齐齐哈尔市| 静海县| 福海县| 万载县| 渭源县| 双江| 霍林郭勒市| 缙云县| 万盛区| 永兴县| 甘洛县| 夹江县| 东乌| 平罗县| 修文县| 扬州市| 天津市| 富源县| 巍山| 亳州市| 贵溪市| 周至县| 镶黄旗| 深水埗区| 东平县| 宜阳县| 德格县| 连平县| 贵阳市| 海宁市| 崇义县| 沈阳市| 襄垣县| 中牟县|