Oracle 在RMAN中使用SQL的规则

说明:本文为在RMAN中使用SQL的规则指导手册
温馨提示:如果您发现本文哪里写的有问题或者有更好的写法请留言或私信我进行修改优化

  • 本文目的:Use the SQL command to execute a SQL statement or a PL/SQL stored procedure from within RMAN.
  • 语法

  • 说明
Syntax Element Description
CHANNEL channel_id ▶Specifies the case-sensitive name of a channel to use when executing an RMAN
command within a RUN command.
▶The channel must have been allocated using ALLOCATE CHANNEL in this RUN command. If
you do not set this parameter, then RMAN uses the default channel.
'command'

▶Specifies a SQL statement for execution (SQL "ALTER SYSTEM ARCHIVE LOG CURRENT";). SELECT statements are not permitted.
▶You must use duplicate single quotes to insert a single quote into a quoted string when
the quoted string uses the same style of quoting. For example, if the string that RMAN
passes to SQL contains a file name, then the file name must be enclosed in duplicate
single quotes and the entire string following the SQL keyword must be enclosed in double
quotes .

SQL "alter database datafile ''+DATA/xxx'' offline";
▶Note: Because EXECUTE is a SQL*Plus command, you cannot execute a PL/SQL program unit by specifying EXECUTE within the RMAN SQL command. Instead, you must use the
BEGIN and END keywords. For example, to execute the PL/SQL procedure rman.rman_
purge with the SQL command, issue the following command:
SQL 'BEGIN rman.rman_purge; END;';

  • 译文:
语法元素 描述
CHANNEL channel_id

▶指定通道的名称(区分大小写)执行RMAN时使用运行命令中的命令。

▶通道一定是分配使用分配通道运行命令。如果不设置此参数,则RMAN使用默认通道。

'command'

▶指定执行的SQL语句 (SQL "ALTER SYSTEM ARCHIVE LOG CURRENT";). 

不允许使用SELECT语句。

▶你必须使用重复的单引号将单引号插入引用字符串时引用的字符串使用相同的引用样式。例如,如果字符串表示RMAN传递给SQL的文件包含一个文件名,那么文件名必须包含在副本中SQL关键字后面的单引号和整个字符串必须用双引号括起来引号。

SQL“alter database datafile”+DATA/xxx“ offline”;     【中间的datafile使用4个英文单引号括起来】

▶注意:因为执行一个SQL * +命令,你不能执行PL / SQL程序单元通过指定执行在RMAN SQL命令。相反,您必须使用开始和结束关键字。例如,要执行PL/SQL过程rman.rman_purge,发出以下命令:

SQL 'BEGIN rman.rman_purge; END;';

   

over

发布了39 篇原创文章 · 获赞 38 · 访问量 3570

猜你喜欢

转载自blog.csdn.net/zzt_2009/article/details/105423610