oracle课堂笔记--第二十一天

死锁:

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     select * from t1 for update;

撤销管理

什么是撤销数据:

 

 

1.交易的回退:没有提交的交易可以rollback

2.交易的恢复:数据库崩溃时,将磁盘的不正确数据恢复到交易前

3.读一致性  :被查询的记录有事务占用,转向回滚段找改前镜像

4.闪回数据  :从回滚段中构造历史数据

事务与撤销数据:

 

 redo和undo:

 AUM:

3个参数,两个表空间属性

 

undo_management=AUTO 回滚表空间段的段管理模式,管理员只需要备足够的表空间容量,oracle会自动管理扩展回滚段的数量。只能使用一个UNDO表空间。

undo_tablespace:只有在自动管理模式下才可以使用。指明使用哪个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:

调度作业

 $ ps -ef | grep cjq

SQL> show parameter job_queue_processes

后台预先设置的自动化管理作业:

 

自定义作业:

SQL> create table session_history(snap_time timestamp with local time zone, num_session number);

em中创建作业:

使用plsql块:

declare

  session_count  number;

begin

  select count(*) into session_count from v$session;

  insert into session_history values (systimestamp, session_count);

  commit;

end;

select * from session_history;

全球化支持

$ vi .bash_profile

#export NLS_LANG=american_america.AL32UTF8

#export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'

$ unset NLS_LANG

$ unset NLS_DATE_FORMAT

SQL> select sysdate from dual;

posted on 2017-08-14 08:56  看透ら不说透  阅读(129)  评论(0编辑  收藏  举报