RMAN 提示符下执行SQL语句

发表于:2013-6-08 10:17

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:RobinsonCheng    来源:51Testing软件测试网采编

  在手动恢复数据库时,有时候需要在SQL*Plus提示符以及操作系统提示符,RMAN提示符下来回切换显得有些繁琐。实际上RMAN为我们提供了命令行下执行一些简单的SQL语句以及PL/SQL的方法,以避免上述情形。本文描述了RMAN提示符下的一些常用命令及其用法。

  1、RMAN提示符下执行SQL语句

  语法: SQL '<command>' ;

  语法比较简单,就是提示符下输入SQL,后接SQL命令,命令用单引号括起来

  command 通常为可执行的SQL命令语句,也可以为PL/SQL块

  使用限制

    如果SQL语句中包含文件名,则文件名及路径需要使用两个单引号括起来,整个SQL语句首尾需要使用双引号

    可以执行SQL查询语句,但是无任何结果输出

  RMAN提示符下常用的命令

    startup [nomount | mount], shutdown immediate
    alter system archive log current
    alter database open [resetlogs]

  2、演示RMAN提示符下执行SQL语句

  a、执行常用的starup, alter SQL 语句

robin@SZDB:~> export ORACLE_SID=GOBO1
robin@SZDB:~> rman target /

Recovery Manager: Release 10.2.0.3.0 - Production on Tue Jun 4 11:04:26 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     536870912 bytes

Fixed Size                     2074080 bytes
Variable Size                314575392 bytes
Database Buffers             213909504 bytes
Redo Buffers                   6311936 bytes

RMAN> alter database mount;

using target database control file instead of recovery catalog
database mounted

RMAN> alter database open;

database opened

RMAN> list copy of archivelog all;   --->查看当前数据库的归档日志,列出了1个已归档日志


List of Archived Log Copies
Key     Thrd Seq     S Low Time          Name
------- ---- ------- - ----------------- ----
2084    1    8       A 20130604 09:53:17 /u02/database/GOBO1/archive/arch_816906485_1_8.arc

RMAN> sql ' alter system archive log current ';   --->对当前日志进行归档

sql statement:  alter system archive log current

RMAN> list copy of archivelog all;                --->归档后可以看到多出了1个已归档日志

List of Archived Log Copies
Key     Thrd Seq     S Low Time          Name
------- ---- ------- - ----------------- ----
2084    1    8       A 20130604 09:53:17 /u02/database/GOBO1/archive/arch_816906485_1_8.arc
2085    1    9       A 20130604 10:46:36 /u02/database/GOBO1/archive/arch_816906485_1_9.arc

21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号