Recovery Catalog   «Prev  Next»

Lesson 6 Stored scripts
Objective Create and use Stored Oracle Rman Scripts

Create Oracle Rman Scripts

One of the most vexing problems a DBA has is how to automate tasks to eliminate potential operator errors. One way to do this is to use stored scripts, which is a feature of Recovery Manager. It is recommended that you seriously consider creating stored scripts for most if not all of your regular DBA tasks.
You will use four primary commands with Recovery Manager to work with stored scripts:

create To create and store scripts in the recovery catalog
delete To delete scripts from the recovery catalog
print To print the contents of a stored script
replace To replace an existing stored script with a new stored script


The basic syntax for creating a stored script is:
create script script_name {<commands>;}

where <commands> is a set of operations that you want to perform.
An example of a script to back up the USER_DATA tablespace is:
RMAN > create script backup_usr1orcl{
2> allocate channel ct type disk;
3> backup

We will discuss the command syntax in later modules. What is important to observe is that Recovery Manager compiles and stores the script in the recovery catalog. If there are any syntax problems, Recovery Manager will report them immediately. But it is important to note that there is no check to determine if the USER_DATA tablespace exists.


The basic syntax for deleting a stored script is:
delete script script_name;


The basic syntax for a print of a stored script is:
print script script_name;

An example output of the script that we created earlier is:


The basic syntax of a replace is:
replace script script_name {<commands>;}
The complete syntax of the stored script is beyond the scope of this course. Your current objective is to understand how to manipulate scripts within Recovery Manager. Although you may store these scripts within Recovery Manager, they can also be stored in your file system.
In the next lesson, you will learn about the run command, which allows you to execute your stored scripts.