第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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復:polardb資料庫備份與恢復資料庫
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- 資料庫備份恢復資料庫
- postgresql備份與恢復資料庫SQL資料庫
- 資料庫備份與恢復技術資料庫
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- PostgreSql資料庫的備份和恢復SQL資料庫
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- MySQL-19.資料庫備份與恢復MySql資料庫
- Dedecms資料庫恢復與備份的兩種方法資料庫
- 淺談達夢資料庫的備份與恢復資料庫
- Mongo 資料庫備份和恢復命令Go資料庫
- pg_dump 備份,恢復資料庫資料庫
- mysqldump使用方法(MySQL資料庫的備份與恢復)MySql資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- 分散式文件儲存資料庫之MongoDB備份與恢復分散式資料庫MongoDB
- 時序資料庫InfluxDB之備份和恢復策略資料庫UX
- 時序資料庫 InfluxDB 之備份和恢復策略資料庫UX
- Mysql資料備份與恢復MySql
- vivo 資料庫備份恢復系統演化資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- PG-pg_dump備份/恢復資料庫資料庫
- oracle資料庫備份之exp增量備份Oracle資料庫
- NoSQL 資料庫案例實戰 -- MongoDB資料備份、恢復SQL資料庫MongoDB
- 資料庫備份資料庫
- RabbitMQ如何備份與恢復資料MQ
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- gitlab的資料備份和恢復Gitlab
- RAC備份恢復之Voting備份與恢復
- 如何在HarmonyOS對資料庫進行備份,恢復與加密資料庫加密
- Dedecms備份的資料檔案位置及備份資料庫的方法資料庫
- ClickHouse資料庫單機安裝及備份恢復資料庫
- mysql 資料庫 備份MySql資料庫
- 資料庫備份策略資料庫
- MongoDB資料庫備份MongoDB資料庫
- MSSQL-最佳實踐-資料庫恢復模式與備份的關係SQL資料庫模式