分离job必须指向一个程序对象,程序对象的分离属性设置为true。下面的盒子是在Linux和系统上创建一个夜间job来对数据库执行备份。
1.创建一个脚本来调用RMAN备份脚本,脚本名为$ORACLE_HOME/scripts/backup.sh
[oracle@sjjh scripts]$ vi backup.sh
export ORACLE_HOME=/home/app/oracle/product/11.2.0
export ORACLE_SID=sjjh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
$ORACLE_HOME/bin/rman TARGET / @$ORACLE_HOME/scripts/backup.rman
trace /home/app/oracle/backup/backup.out &
exit 0
2.创建rman备份脚本,脚本名为$ORACLE_HOME/scripts/backup.rman
[oracle@sjjh scripts]$ vi backup.rman
run{
# Perform full database backup
backup full format "/home/app/oracle/backup/%d_FULL_%U" (database) ;
# Open database after backup
alter database open;
# Call notification routine to indicate job completed successfully
sql " BEGIN DBMS_SCHEDULER.END_DETACHED_JOB_RUN(''sys.backup_job'', 0,
null); END; ";
}
3.创建job并使用分离程序对象