14、管理undo
14、管理 oracle undo
1、DML與undo
undo data:
原始的、修改之前的數據副本
用於支持:回退操作、讀一致性查詢、閃回查詢、閃回事務處理及閃回表、從失敗事務中進行恢復。
undo:舊數據
redo:改變的數據
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string
undo_retention integer 900
undo_tablespace string UNDOTBS1
undo_retention指定已經提交的還原信息要保留多長時間(秒)
undo表空間大小設置多大合適呢?
select name,BLOCK_SIZE/1024/1024 from v$datafile;
設置undo手動管理(需要重啟數據庫) ==不建議手動管理
alter system set undo_management=manual scope=spfile;
v$rollname
select * from v$rollname;
如何創建undo表空間?
SQL> select name from v$datafile;
NAME
--------------------------------------------------
+DATA/orcl/datafile/system.256.943301251
+DATA/orcl/datafile/sysaux.257.943301251
+DATA/orcl/datafile/undotbs1.258.943301251
+DATA/orcl/datafile/users.259.943301251
+DATA/orcl/datafile/example.265.943301433
+DATA/orcl/datafile/tbs.dbf
create undo tablespace untotbs2 datafile ‘+DATA/orcl/datafile/undotbs2.dbf‘ size 3m;
show parameter undo
alter system set undo_tablespace=untotbs2;//設置undo表空間為untotbs2
SQL> show parameter undo;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNTOTBS2
2、undo管理及使用
查看表空間是否自動擴展
SQL> select TABLESPACE_NAME,AUTOEXTENSIBLE from dba_data_files;
TABLESPACE_NAME AUT
------------------------------ ---
USERS YES
UNDOTBS1 YES
SYSAUX YES
SYSTEM YES
EXAMPLE YES
TBS_16K NO
UNTOTBS2 NO
undo快照過舊
SQL> select CURRENT_SCN from v$database;
CURRENT_SCN
-----------
2366951
################################################
例子:scn 閃回查詢 15分鐘。
SQL> create table t2 as select * from scott.emp;
Table created.
SQL> select CURRENT_SCN from v$database;
CURRENT_SCN
-----------
2367095
SQL> delete t2;
14 rows deleted.
SQL> commit;
Commit complete.
SQL> select count(*) from t2 as of scn 2367095;
COUNT(*)
----------
14
###################################################
本文出自 “梁小明的博客” 博客,請務必保留此出處http://7038006.blog.51cto.com/7028006/1939548
14、管理undo