Oracle 12c 新特性 --- RMAN命令行執行SQL語句

概述

Recovery Manager (RMAN) command-line interface has been enhanced to:

•	Run SQL as-is at the command line, no longer requiring the SQL command.
•	Support SELECT statements.
•	Support the DESCRIBE command on tables and views.

These enhancements provide better ease-of-use when running SQL in an RMAN session.

恢復管理器(RMAN)命令行界面已增強:

運行SQL as-is在命令行,不再需要SQL命令。
支持SELECT語句。
在表和視圖上支持DESCRIBE命令。

這些增強在RMAN會話中運行SQL時提供了更好的易用性。

SQL Interface Improvements
You can now issue most SQL commands in RMAN without preceding the command with the SQL keyword. For a few commands that exist in both RMAN and SQL and have very different uses, you can specify the SQL keyword to eliminate ambiguity. You no longer need to enclose the SQL command in quotes, which greatly simplifies the syntax when the SQL command itself requires quotation marks. The SQL ALTER command replaces the RMAN command.

The new RMAN DESCRIBE command provides the functionality of the SQL*Plus DESCRIBE command.
現在,您可以在RMAN中發出大多數SQL命令,而無需使用SQL關鍵字。對於在RMAN和SQL中存在的一些命令,並且有非常不同的用途,您可以指定SQL關鍵字來消除歧義。您不再需要將SQL命令括在引號中,這大大簡化了SQL命令本身需要引號的語法。SQL ALTER命令替代RMAN命令。

新的RMAN描述命令提供了SQL * Plus描述命令的功能。

具體 RMAN 可執行哪些SQL 命令 可參考:
http://docs.oracle.com/database/121/RCMRF/rcmsynta2018.htm#RCMRF90631

實驗

1) 11g 版本 RMAN 命令行執行SQL 命令要SQL關鍵字
RMAN> ALTER SYSTEM SWITCH LOGFILE

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "database"
RMAN-01008: the bad identifier was: SYSTEM
RMAN-01007: at line 1 column 7 file: standard input

RMAN>  SQL "ALTER SYSTEM SWITCH LOGFILE";

sql statement: ALTER SYSTEM SWITCH LOGFILE

2)12c 執行命令可以使用SQL 關鍵字,也可以不使用
--執行alter 命令
RMAN> SQL ALTER SYSTEM SWITCH LOGFILE;

using target database control file instead of recovery catalog
Statement processed

RMAN> ALTER SYSTEM SWITCH LOGFILE;

Statement processed

RMAN> ALTER TABLESPACE users ADD DATAFILE '/u01/app/oracle/oradata/cndba/users02.dbf' SIZE 1M AUTOEXTEND ON NEXT 10K MAXSIZE 2M;

Statement processed
--執行select 命令
RMAN> SELECT dbid FROM v$database;

      DBID
----------
 215559030
--執行create 命令
RMAN> CREATE DIRECTORY dest_dir AS '/backup';               

Statement processed

參考鏈接:

http://docs.oracle.com/database/121/NEWFT/chapter12101.htm#NEWFT002

http://docs.oracle.com/database/121/BRADV/release_changes.htm#BRADV623

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章