新建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

oracle重置口令是什么意思,Oracle重置数据库命令相关推荐

  1. oracle scn 重置,学习笔记:Oracle SCN详解 SCN与Oracle数据库恢复的关系

    天萃荷净 分享一篇关于Oracle SCN的详解,介绍SCN与Oracle数据库恢复的关系和SCN在数据库中的作用 一.为什么需要System checkpoint SCN号与Datafile Che ...

  2. Oracle的口令文件(passwordfile)的讲解(摘录)

    初学oracle,很多概念迷糊,今天看到这文章,让我有一个比较清晰的认识. 转载[url]http://www.itpub.net/viewthread.php?tid=906008&extr ...

  3. oracle启动文件是什么意思,Oracle数据库的启动——口令文件的作用

    在Oracle 10g之前,启动到Mount状态,数据库需要具备的另外一个重要文件是口令文件,在Unix/Linux上,该文件位于$ORACLE_HOME/dbs目录下,缺省的名称为orapw. 而在 ...

  4. oracle 数据库口令,oracle的口令资料

    oracle的口令文件 Oracle中的口令文件存放着系统的特权用户(sysdba, sysoper)用户的用户名及口令,允许用户通过口令文件验证,在数据库未启动之前登陆从而启动数据库.如果没有口令文 ...

  5. oracle常用口令

    1. Oracle安装完成后的初始口令?  internal/oracle  sys/change_on_install  system/manager  scott/tiger  sysman/oe ...

  6. oracle的口令就是密码吗,如何修改Oracle用户的密码(不改变原密码)

    如何修改Oracle用户的密码 有的人回答说这个不是很简单吗 alter user identified by +密码 如果不知道用户的密码情况下,不能改变原始密码呢(适用于用户密码过期) 测试如下 ...

  7. 总结一:Oracle 数据库命令总结

    一.日志管理 1.强制日志切换(forcing log switches) alter system switch logfile;2.强制执行检查点(forcing checkpoints) alt ...

  8. Oracle 数据库命令个人总结

    一.日志管理 1.强制日志切换(forcing log switches) alter system switch logfile;2.强制执行检查点(forcing checkpoints) alt ...

  9. oracle 配置账户密码是多少,【ORACLE】oracle数据库用户密码复杂度配置

    -- 设置密码复杂度 SQL> @ /u01/app/oracle/product/11.2.0/db_1/rdbms/admin/utlpwdmg.sql -- 测试 SQL> alte ...

  10. oracle中imp命令详解,ORACLE EXPDP IMPDP数据导入导出命令详解及同EXP IMP命令详细对照...

    ORACLE EXPDP IMPDP数据导入导出命令详解及同EXP IMP 命令详细对比 一.EXPDP IMPDP EXP IMP 可以实现 1.可以实现逻辑备份和逻辑恢复 2.可以在数据库用户之间 ...

最新文章

  1. NLP文本生成模型数据准备及实战
  2. 利用tab_control控件在对话框中加入属性页的方法详细介绍
  3. 将protobuf文档转换成java代码
  4. 跨部门不配合工作_跨部门协作,队友总是“甩锅”,这三个方法教你快速避坑!...
  5. notepad++ 偶数行_C ++程序查找前N个偶数的立方和
  6. Mysql for Linux安装配置之——二进制安装
  7. shell waite php,linux shell wait命令详解
  8. Vue3.0 + Ts 项目框架搭建二:路由 Router
  9. Apache OpenNLP提供的文档
  10. CentOS7安装GNOME可视化界面 和 远程访问
  11. PMP考试通关宝典-敏捷专题
  12. 主动轮廓线模型Snake模型简介amp;openCV中cvSnakeImage()函数代码分析
  13. 一种便携式导弹飞控系统外场实时仿真测试系统设计
  14. VB中产生10个不重复的随机数
  15. SSH登录的两种方式
  16. 佳能mp288打印机连供系统使用
  17. vue3 项目中如何输出webpack的config.js
  18. 低市值高业绩的TCL,能否借“元宇宙”风口说新故事?
  19. 微信小程序界面设计的好方法
  20. vue打包上线部分css效果错乱,解决Vue打包上线之后部分CSS不生效的问题

热门文章

  1. c++primer 容器算法整理一
  2. NClay框架AOP功能简介
  3. MySQL 和 MySQL Workbench图形化安装教程
  4. LeetCode_125_Python_验证回文串
  5. vue跨域/webpack跨域
  6. Spring Cloud - Nacos 注册中心入门单机模式及集群模式
  7. Keil自动格式化代码
  8. Android实现计算器布局(线性布局)
  9. 什么是ajax?ajax作用是什么?
  10. 排序算法、数据结构动态图、动态运行效果