第5章:從開啟的資料庫備份與恢復之備份開啟的資料庫
/* 2008/05/27
*環境:Windows XP +Oracle10.2.0.1
*Oracle 備份與恢復培訓教程 Kenny Smith,Stephan Haisley著 周琪、韓岷、李渝琳等譯
*第二部分:使用者管理的備份與恢復
*第5章:從開啟的資料庫備份與恢復
*/
練習5.1:備份開啟的資料庫
1、產生資料庫活動
SQL> insert into tina.date_log values(sysdate);
已建立 1 行。
SQL> alter system switch logfile;
系統已更改。
2、建立備份指令碼
建立e:\open_backup.sql指令碼
指令碼內容:
Set feedback off pagesize 0 heading off verify off linesize 100 trimspool on
define dir='e:\backup'
define fil='e:\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' and tablespace_name<>'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 alter database backup controlfile to '&dir\backup.ctl' reuse;;
prompt archive log list;;
prompt spool off;;
spool off;
@&fil
3、執行熱備份指令碼
SQL> @e:\open_backup.sql
註釋:使用者表空間置於備份模式,檢視聯機資料檔案的備份狀態:
SQL> alter tablespace users begin backup;
表空間已更改。
SQL> select d.tablespace_name tablespace,b.file#,
2 b.status,b.change#,b.time
3 from dba_data_files d,v$backup b
4 where b.file#=d.file_id
5 order by tablespace_name;
TABLESPACE FILE# STATUS CHANGE# TIME
-------------- ---------- ------------------ ---------- --------------
RISE 5 NOT ACTIVE 572699 27-5月 -08
SYSAUX 3 NOT ACTIVE 572668 27-5月 -08
SYSTEM 1 NOT ACTIVE 572636 27-5月 -08
UNDOTBS1 2 NOT ACTIVE 572655 27-5月 -08
USERS 4 ACTIVE 573763 27-5月 -08
SQL> alter tablespace users end backup;
表空間已更改。
4、檢查備份命令
檢視e:\open_bakcup_commands.sql檔案,該檔案中的命令是否正確。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12778571/viewspace-312655/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 第5章:從開啟的資料庫備份與恢復之從開啟的資料庫備份中完全恢復資料庫
- 第5章:從開啟的資料庫備份與恢復之從開啟的資料庫備份中進行不完全恢復資料庫
- 第5章:從開啟的資料庫備份與恢復之備份歸檔日誌檔案資料庫
- 【備份恢復】從備份恢復資料庫資料庫
- 資料庫的備份與恢復資料庫
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- 備份與恢復:polardb資料庫備份與恢復資料庫
- mysql的資料庫備份與恢復MySql資料庫
- oracle資料庫的備份與恢復Oracle資料庫
- postgresql備份與恢復資料庫SQL資料庫
- mongo資料庫備份與恢復Go資料庫
- Informix資料庫備份與恢復ORM資料庫
- Oracle資料庫備份與恢復之RMANOracle資料庫
- 資料庫資料的恢復和備份資料庫
- 關閉資料庫的備份與恢復資料庫
- Oracle資料庫的備份與恢復(轉)Oracle資料庫
- Oracle 資料庫的備份與恢復(轉)Oracle資料庫
- rman資料庫全庫備份與恢復資料庫
- 資料庫備份與異機恢復——熱備份方式資料庫
- Oracle資料庫備份與恢復之三:OS備份/使用者管理的備份與恢復Oracle資料庫
- 資料庫備份與恢復技術資料庫
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- PostgreSql資料庫的備份和恢復SQL資料庫
- DB2的資料庫備份與恢復DB2資料庫
- ORACLE RAC資料庫的備份與恢復(6)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(5)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(4)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(3)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(2)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(1)Oracle資料庫
- 資料庫(表)的邏輯備份與恢復資料庫
- 備份與恢復--從備份的歸檔日誌中恢復資料
- 【備份恢復】noarchive模式下使用增量備份恢復資料庫Hive模式資料庫
- RMAN備份恢復——RAC環境資料庫的備份(zt)資料庫
- RMAN備份恢復--RAC環境資料庫的備份(十)資料庫
- RMAN備份恢復——RAC環境資料庫的備份(一)資料庫
- Oracle資料庫備份與恢復之RMAN2Oracle資料庫
- 達夢資料庫備份恢復資料庫