Tuesday, February 3, 2009

Check syntax of rman commands

on a production environment , we normally run backup as a scheduled script. So, we want our script should not face any syntax errors while executing.

Is there a way to check the syntax before executing ?
answer is YES . we can.

Rman has an utility to check the syntax . that is checksyntax .
It will not execute the commands directly . it will only check the syntax and give a report.
Let us check:

c:\ershad>rman checksyntax

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 3 11:32:44 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN>

So, let us try with a valid command.

RMAN> list backup of datafile 99;

OUTPUT:
The command has no syntax errors

so, we know it is a valid command.
check with a invalid command now. ( The valid command is , list backup of datafile 99)
RMAN> list backup datafile 99;

OUTPUT:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "datafile": expecting one of: "by, backed, completed, controlfile, device, like, of, recoverable, ;, summary, tag, verbose"
RMAN-01007: at line 1 column 13 file: standard input


so, now i hope we understand the utility .
Note: remember this parameter/argument should be passed to rman while you are connecting to rman. in rman prompt we cannot initiate this checksyntax.
One more thing , it will only check the syntax . not the execution of the statement . assume
rman> list backup of datafile 99;
the above command output is :
The command has no syntax errors

though i dont have a datafile 99 in my database(as the syntax is correct)

we can check rman cmd files also through this. example:

C:\ershad>rman checksyntax @c:\w.txt
OUTPUT:
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 3 11:54:01 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> backup datafile 1;
2> backup datafile 45;
3> show all;
4> list backup of datafile 1;
5>
The cmdfile has no syntax errors
Recovery Manager complete.

or we can try this also:

RMAN> @c:\w.txt
OUTPUT:
RMAN> backup datafile 1;
The cmdfile has no syntax errors
RMAN> backup datafile 45;
The cmdfile has no syntax errors
RMAN> show all;
The cmdfile has no syntax errors
RMAN> list backup of datafile 1;
The cmdfile has no syntax errors
RMAN> **end-of-file**
RMAN>


If we want we can connect to target database also on the same time:
C:\ershad>rman checksyntax target /@lion

but as i told , it is not of any use , as this will only check the syntax, not the execution part of it.


thanks
have a nice day........

Take calculated risks. That is quite different from being rash.
George S. Patton

No comments: