Viewing a Stored Script

To view the stored catalog scripts from within RMAN, there’s a print script command:

print script script_name;

To view the script that we just stored, invoke RMAN, connect to both the target and the catalog, and then print the script:

$ rman target / catalog rman_901/rman_901_pwd@rman_catalog
RMAN> print script full_back;

If you want to see all source code stored in the catalog, you can do so by querying from two RMAN views: rc_stored_script and rc_stored_script_line:

SQL> desc rc_stored_script
 Name                       Null?    Type
 -------------------------- -------- ----------
 DB_KEY                     NOT NULL NUMBER
 DB_NAME                    NOT NULL VARCHAR2(8)
 SCRIPT_NAME                NOT NULL VARCHAR2(100)

SQL> desc rc_stored_script_line
 Name                       Null?    Type
 -------------------------- -------- ----------
 DB_KEY                     NOT NULL NUMBER
 SCRIPT_NAME                NOT NULL VARCHAR2(100)
 LINE                       NOT NULL NUMBER
 TEXT                       NOT NULL VARCHAR2(1024)

To view all stored script code associated with your target database, log in with SQL*Plus as the schema that owns the objects in the catalog and run the following script:

COLUMN script_name FORMAT A10
COLUMN text        FORMAT A65

SELECT
  a.script_name,
  a.text
FROM rc_stored_script_line a,
     rc_stored_script      b
WHERE a.db_key = b.db_key
AND   b.db_name='YOUR_TARGET_DATABASE_NAME'
ORDER BY
  a.line
/

Run the script from SQL*Plus, and the output will look something like:

SCRIPT_NAM TEXT ---------- ----------------------------------- full_back { full_back allocate channel d1 type disk; full_back backup full format '/d0102/backup/rman_%d_%U.bus' ...

Get Oracle RMAN Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.