我没经验,这是在网上看到的,试过还可以
------------------------------------
1.建立批处理文件,内容:
sqlplus -s system/manager@tenjak @D:tenjakback.sql >> D:hot.log
sqlplus -s system/manager@tenjak @D:tenjak_back.sql >> D:hot2.log
exit
-------------------------------------
2.备份文件
define HOT_BACK_DIR = H:backup
define INT_PWD = manager
define BACK_DATE = to_char(sysdate,'ddmmyy')
set heading off
prompt backup on
select 'prompt' || to_char(sysdate,'dd/mm/yyyy') from dual;
/* Create Temporary Table with Tablespace Data */
drop table dsc_hot_stage;
create table dsc_hot_stage
(
tablespace_name varchar2(30),
file_name varchar2(200)
);
insert into dsc_hot_stage
select rtrim(tablespace_name),rtrim(file_name) from sys.dba_data_files;
set feedback off
set heading off
set pagesize 0
set linesize 85
set verify off
set termout off
set echo off
break on c2 on c1
spool D:tenjak_back.sql
select 'prompt ' || to_char(sysdate,'dd/mm/yyyy hh24:mi:ss') from dual;
select 'connect system/&INT_PWD'||'@tenjak as sysdba' from dual;
-- Create Script to backup actual files to a directory
select 'prompt ' || tablespace_name|| ' begin backup' c1,
'alter tablespace '|| tablespace_name||' begin backup;' c2,
'host ocopy '||file_name||' &HOT_BACK_DIR' || '' ||
substr(file_name,instr(rtrim(file_name),'',-1,1)+1,length(rtrim(file_name))) c3 from dsc_hot_stage
union
select
'prompt ' || tablespace_name || ' end backup' c1,
百度搜索“爱华网”,专业资料、生活学习,尽在爱华网!