求SQL语句,备份、还原ORACLE数据库,最好在数据库处于打开状态下也能做,热备份
然后我要把这个SQL语句放在VB程序里,比如用SQL SERVER的数据库的话,就在VB程序里这样写就可以了:
GeoCnn.Execute "backup database SEWERAGE to disk = 'E:'"
GeoCnn.Execute "restore database SEWERAGE from disk = 'E:'"
我想知道换成ORACLE后,语句怎么写了?
给个热备的脚本,然后生成一个bat文件来执行,bat的内容为:sqlplus "/as sysdba" @hotback.sql。
[php]
rem script:hotback.sql
rem purpose:hot backup whole database
rem creater:xuexb
rem date:20040725
rem last_changed_date:20041127
set feedback off pagesize 0 heading off
verify off linesize 100 trimspool on
define dir='F:\\db'
define fil='F:\\db\open_backup_commands.sql'
define spo='&dir\\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' or 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
[/php]