自己看看吧,应该有些帮助
set feedback off pagesize 0 heading off verify off linesize 100 trimspool on
define dir = 'd:\backup2'
define fil = 'd:\open_backup_commands.sql'
define spo = 'd:\open_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 status <> 'READ ONLY' and CONTENTS <> 'TEMPORARY';
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 alter database backup controlfile to '&dir\backup.ctl' REUSE;;
prompt archive log list;;
prompt spool off;;
spool off;
@&fil
set feedback off pagesize 0 heading off verify off linesize 100 trimspool on
define dir = 'd:\backup2'
define fil = 'd:\open_backup_commands.sql'
define spo = 'd:\open_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 status <> 'READ ONLY' and CONTENTS <> 'TEMPORARY';
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 alter database backup controlfile to '&dir\backup.ctl' REUSE;;
prompt archive log list;;
prompt spool off;;
spool off;
@&fil
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货