SET feedback OFF
SET pagesize 0
SET heading OFF
SET verify OFF
SET linesize 100
SET trimspool ON
define dir = '/oracle'
define fil = '&dir/backup_commands.sql'
define spo = '&dir/backup_output.lst'
prompt ***Spooling TO &fil
SET serveroutput ON
spool &fil
prompt spool &spo
prompt ARCHIVE LOG LIST;;
prompt ALTER SYSTEM SWITCH LOGFILE;;
DECLARE
CURSOR cur_tablespace IS SELECT Tablespace_name FROM dba_tablespaces WHERE tablespace_name
NOT like '%TEMP%';
CURSOR cur_datafile(tn VARCHAR) IS SELECT file_name FROM dba_data_files WHERE tablespace_name
= tn;
BEGIN
FOR ct IN cur_tablespace LOOP
dbms_output.put_line('alter tablespace '||ct.tablespace_name || ' begin backup;');
FOR cd IN cur_datafile(ct.tablespace_name) LOOP
dbms_output.put_line('host copy '|| cd.file_name || ' &dir');
END LOOP;
dbms_output.put_line('alter tablespace '||ct.tablespace_name || ' end backup;');
END LOOP;
END;
/
prompt ALTER SYSTEM SWITCH LOGFILE;;
prompt spool OFF;;
spool off;
exit
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13790829/viewspace-430026/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13790829/viewspace-430026/