Skip Headers
Oracle® Database Backup and Recovery Reference
11g Release 1 (11.1)

Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
PDF · Mobi · ePub



Use the EXECUTE SCRIPT command to run a local or global RMAN script stored in the recovery catalog.

See Also:


Use EXECUTE SCRIPT only within the braces of a RUN command. RMAN must be connected to the recovery catalog with the CATALOG command-line option or the CONNECT CATALOG command. The recovery catalog database must be open.

Usage Notes

When you run an EXECUTE SCRIPT command within a RUN block, RMAN places the contents of the script in the context of that RUN block. For this reason, you should not allocate a channel within the RUN block if you also allocate it in the script.

If GLOBAL is specified, then a global script with this name must already exist in the recovery catalog; otherwise, RMAN returns error RMAN-06004. If GLOBAL is not specified, then RMAN searches for a local stored script defined for the current target database. If no local script with this name is found, then RMAN searches for a global script by the same name and executes it if one is found.



Description of executescript.gif follows
Description of the illustration executescript.gif


Syntax Element Description
GLOBAL Specifies the execution of a global stored script instead of a local one.

See Also: "Usage Notes" for an explanation of the difference between global and local scripts

SCRIPT script_name Specifies the name of the stored script to execute. Quotes must be used around the script name when the name contains either spaces or reserved words.

   | integer]
Specifies one or more values for use in substitution variables in a stored script (see Example 2-77).

See Also: CREATE SCRIPT to learn how to create a stored script with substitution variables, and RMAN and @ (at sign) to learn how to use substitution variables with RMAN


Example 2-76 Executing a Stored Script

This example uses LIST to list the script stored in the recovery catalog and PRINT SCRIPT to show the contents of global_backup_db, which was created in Example 2-59, "Creating a Global Stored Script". Finally, the example runs global_backup_db to back up the database.

List of Stored Scripts in Recovery Catalog

    Global Scripts

       Script Name
       back up any database from the recovery catalog, with logs

RMAN> PRINT SCRIPT global_backup_db;

printing stored global script: global_backup_db

RMAN> RUN { EXECUTE GLOBAL SCRIPT global_backup_db; }

executing global script: global_backup_db

Starting backup at 07-JUN-07
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=120 device type=DISK

Example 2-77 Creating and Executing a Stored Script That Uses Substitution Variables

After starting RMAN and connecting to a target database and recovery catalog, use REPLACE SCRIPT to create a backup script that includes three substitution variables. RMAN prompts you to enter initial values for the variables (user input is in bold).

2>  backup_df { BACKUP DATAFILE &1 TAG &2.1 FORMAT '/disk1/&3_%U'; }
 Enter value for 1: 1
Enter value for 2: df1_backup
Enter value for 3: df1

starting full resync of recovery catalog
full resync complete
created script backup_df

Later, you can execute the backup_df script with different values. The following example passes the values 3, test_backup, and test to the substitution variables in the stored script:

RMAN> RUN { EXECUTE SCRIPT backup_df USING 3 test_backup df3; }

After the values are substituted, RMAN executes the BACKUP command as follows:

BACKUP DATAFILE 3 TAG test_backup1 FORMAT '/disk1/df3_%U';