在生产环境中,假如要部署一套RMAN的备份脚本,那么对脚本的测试就是必不可少的环节,Oracle提供了CHECKSYNTAX命令来协助我们在不用实际执行脚本的情况下检查脚本的语法错误,如:
[oracle@ligle-db ~]$ rman checksyntax
Recovery Manager: Release 10.2.0.4.0 - Production on Sat Mar 26 03:04:18 2011
Copyright (c) 1982, 2007, Oracle.All rights reserved.
RMAN>
RMAN> run [backup database;]
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01006: error signalled during parse
RMAN-02001: unrecognized punctuation symbol "["
再如:
RMAN> run {backup database delete all input;}
The command has no syntax errors
可见,如果在被检命令中检测出语法错误,那么就会报错,如:RMAN-00558。
下面再看下检查RMAN脚本:
加入在/home/oracle目录下存放一脚本cmdfile1,内容是:
restore database;
recover database;
现在执行CHECKSYNTAX命令检查其语法是否存在问题:
[oracle@ligle-db ~]$ rman CHECKSYNTAX @/home/oracle/cmdfile1
Recovery Manager: Release 10.2.0.4.0 - Production on Sat Mar 26 03:16:48 2011
Copyright (c) 1982, 2007, Oracle.All rights reserved.
RMAN> restore database;
2> recover database;
3>
The cmdfile has no syntax errors
Recovery Manager complete.
如果脚本中存在错误,比如去掉cmdfile1中的“;”,则输出就会是:
[oracle@ligle-db ~]$ rman CHECKSYNTAX @/home/oracle/cmdfile1
Recovery Manager: Release 10.2.0.4.0 - Production on Sat Mar 26 03:18:43 2011
Copyright (c) 1982, 2007, Oracle.All rights reserved.
RMAN> restore database
2> recover
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "recover": expecting one of: "archivelog, channel, check, controlfile, clone, database, datafile, device, from, force, high, (, preview, ;, skip, spfile, standby, tablespace, until, validate"
RMAN-01007: at line 2 column 1 file: /home/oracle/cmdfile1
--- END ---
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25834554/viewspace-706601/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25834554/viewspace-706601/