阻塞和死锁的区别:死锁是死循环,阻塞是一个队列。
撤销表空间专门放撤销的数据。撤销段和每一个事物关联在一起。
AUM自动撤销管理,只需指令好表空间,规定好表空间大小,系统会自动管理。
Database: show parameter nls
Client:
.bash_profile
Export NLS_DATE_FORMAT=’yyyy-mm-dd’
SESSION:alter session set nls_date_fomat=’dd-mon yyyy’
Select to_char(sysdate, ‘yyyy, month, dd’)from dual;
影响范围越小的,优先级别越高。
死锁:
session1:
SQL> select * from t1;
X
----------
1
2
SQL> update t1 set x=11 where x=1;
session2:
SQL> update t1 set x=22 where x=2;
session1:
SQL> update t1 set x=222 where x=2; 阻塞
session2:
SQL> update t1 set x=111 where x=1; 死锁
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource
$ vi /u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log
锁和外键
select … for update
撤销管理
什么是撤销数据:
1.交易的回退:没有提交的交易可以rollback
2.交易的恢复:数据库崩溃时,将磁盘的不正确数据恢复到交易前
3.读一致性 :被查询的记录有事务占用,转向回滚段找改前镜像
4.闪回数据 :从回滚段中构造历史数据
事务与撤销数据:
redo和undo:
AUM:
3个参数,两个表空间属性
undo_management=AUTO 回滚表空间段的段管理模式,管理员只需要备足够的表空间容量,oracle会自动管理扩展回滚段的数量。只能使用一个UNDO表空间。保证参数的值一直是auto。
undo_tablespace:只有在自动管理模式下才可以使用。指明使用哪个UNDO表空间。后面跟一个真实存在的表空间的名字。这个表空间的类型是undo类型。
undo_retention=900 :(提交之后应该额外保留的时间)
提交之后旧的镜像保持在回滚段中的时间。
非强制的回退保持时间.(回滚空间不足老的镜像就会被覆盖)
autoextend:表空间自动扩展
强制保持:但是对空间要求较大,要慎用。(10g开始支持)
alter tablespace UNDOTABS1 RETENTION GUARANTEE;
select tablespace_name,RETENTION from dba_tablespaces;
UNDO_RETENTION specifies (in seconds) how long already committed undo information is to be retained. The only time you must set this parameter is when:
•The undo tablespace has the AUTOEXTEND option enabled
•You want to set undo retention for LOBs
•You want to guarantee retention
undo advisor: