当前位置: 首页 > Oracle, Oracle 12c > 正文

ORACLE 12C新特性-在RMAN中运行SQL语句

在12C版本中,又推出了一个很方便的特性,在12C版本的RMAN中,可以直接运行SQL和PL/SQL,不需要在使用SQL前缀。

[oracle@dbdream ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Sat Jan 18 18:48:30 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates.? All rights reserved.
connected to target database: DBDREAM (DBID=2364849259)
RMAN> create table rman_runsql as select object_id,object_name from dba_objects where rownum<=10;

Statement processed

在RMAN中运行SQL语句,比如上面的建表语句,提示不像SQLPLUS里面那样提示Table created(表已创建),而是Statement processed(语句已处理),再看看其他DDL语句的提示。

RMAN> alter table rman_runsql modify (OBJECT_NAME varchar2(30));

Statement processed

我估计在RMAN里运行所有DDL的提示提示都是Statement processed,当然这只是个人猜测,有兴趣的同学可以自行测试,如果不是这样的希望回复我,我就不测试了。

RMAN> select name from v$database;

NAME
---------
DBDREAM

RMAN> select * from rman_runsql;

OBJECT_ID OBJECT_NAME
---------- ------------------------------
61186 /1000323d_DelegateInvocationHa
67693 /1000e8d1_LinkedHashMapValueIt
82944 /1004e416_BaselineTIFFTagSetJP
49220 /1005bd30_LnkdConstant
60142 /10074015_Document1
48121 /10076b23_OraCustomDatumClosur
68169 /100c1606_StandardMidiFileRead
52201 /100c72c8_PseudoSchemaBuilder
62322 /10128284_OpenMBeanAttributeIn
80897 /1013c29d_PlanarImageServerPro

10 rows selected

SELECT语句的提示倒是和SQLPLUS里面的提示一样,在RMAN中同样支持DESC描述对象。

RMAN> desc tab;

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 TNAME                                     NOT NULL VARCHAR2(128)               
 TABTYPE                                            VARCHAR2(7)                 
 CLUSTERID                                          NUMBER                      

但是SHOW命令貌似不支持。

RMAN> show con_name



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: "all, archivelog, auxiliary, auxname, backup, channel, compression, controlfile, datafile, db_unique_name, default, device, encryption, exclude, maxsetsize, retention, snapshot, "

RMAN-01008: the bad identifier was: con_name

RMAN-01007: at line 1 column 6 file: standard input

貌似也不可以使用COLUMN命令格式化列显示长度。

RMAN> col tname for a10

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: "advise, allocate, alter, analyze, associate statistics, audit, backup, begin, @, call, catalog, change, comment, commit, configure, connect, convert, copy, create, create catalog, create global, create script, create virtual, crosscheck, declare, delete, delete from, describe, describe catalog, disassociate statistics, drop, drop catalog, drop database, duplicate, exit, explain plan, flashback, flashback table, grant, grant catalog, grant register, host, import, insert, list, lock, merge, mount, noaudit, open, print, purge, quit, recover, register, release, rename, repair, replace, report, "

RMAN-01008: the bad identifier was: col

RMAN-01007: at line 1 column 1 file: standard input
RMAN> column tname for a10
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: "advise, allocate, alter, analyze, associate statistics, audit, backup, begin, @, call, catalog, change, comment, commit, configure, connect, convert, copy, create, create catalog, create global, create script, create virtual, crosscheck, declare, delete, delete from, describe, describe catalog, disassociate statistics, drop, drop catalog, drop database, duplicate, exit, explain plan, flashback, flashback table, grant, grant catalog, grant register, host, import, insert, list, lock, merge, mount, noaudit, open, print, purge, quit, recover, register, release, rename, repair, replace, report, "

RMAN-01008: the bad identifier was: column

RMAN-01007: at line 1 column 1 file: standard input

 

本文固定链接: https://www.dbdream.com.cn/2014/01/oracle-12c%e6%96%b0%e7%89%b9%e6%80%a7-%e5%9c%a8rman%e4%b8%ad%e8%bf%90%e8%a1%8csql%e8%af%ad%e5%8f%a5/ | 信春哥,系统稳,闭眼上线不回滚!

该日志由 dbdream 于2014年01月19日发表在 Oracle, Oracle 12c 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: ORACLE 12C新特性-在RMAN中运行SQL语句 | 信春哥,系统稳,闭眼上线不回滚!
关键字: , , ,

ORACLE 12C新特性-在RMAN中运行SQL语句:等您坐沙发呢!

发表评论

快捷键:Ctrl+Enter