[20190522]DISABLE TABLE LOCK.txt
[20190522]DISABLE TABLE LOCK.txt
--//如果禁止table lock时,一些ddl操作会被禁止.但是我有点吃惊的是增加字段不受限制.
--//通过测试说明问题.
1.环境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> create table t as select rownum id from dual ;
Table created.
SCOTT@book> alter table t disable table lock;
Table altered.
2.测试:
SCOTT@book> truncate table t;
truncate table t
*
ERROR at line 1:
ORA-00069: cannot acquire lock -- table locks disabled for T
SCOTT@book> alter table t add v1 varchar2(10);
Table altered.
--//增加1列v1没有问题.
SCOTT@book> @ desc t
Name Null? Type
----- -------- ----------------------------
ID NUMBER
V1 VARCHAR2(10)
SCOTT@book> alter table t drop column v1;
alter table t drop column v1
*
ERROR at line 1:
ORA-00069: cannot acquire lock -- table locks disabled for T
--//删除列不行.
SCOTT@book> alter table t set unused column v1;
alter table t set unused column v1
*
ERROR at line 1:
ORA-00069: cannot acquire lock -- table locks disabled for T
3.继续:
SCOTT@book> alter table t enable table lock;
Table altered.
SCOTT@book> alter table t set unused column v1;
Table altered.
--//有时候感觉oracle设计的很奇怪,也就是增加1列不需要TM锁吗?
3.继续测试:即使有事务存在的情况下.
--//session 1:
SCOTT@book> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
30 535 42553 DEDICATED 42554 26 245 alter system kill session '30,535' immediate;
SCOTT@book> alter table t disable table lock;
Table altered.
--//session 2:
SCOTT@book> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
1 10297 43346 DEDICATED 43347 24 237 alter system kill session '1,10297' immediate;
SCOTT@book> insert into t values (2);
1 row created.
SCOTT@book> @ viewlock ;
SID SERIAL# USERNAME OSUSER MACHINE MODULE LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2 OWNER OBJECT_TYP OBJECT_NAME BLOCK LOCKWAIT
------ ---------- ---------- ---------- ---------- ------------ --------------- ---------- ---------- ---------- ---------- ------ ---------- -------------------- ----- --------------------
1 10297 SCOTT oracle gxqyydg4 SQL*Plus TX Transaction Exclusive None 655375 4583723 No
--//session 1:
SCOTT@book> alter table t add v1 varchar2(10);
Table altered.
SCOTT@book> alter table t add v2 varchar2(10);
Table altered.
--//确实可以.
--//session 2:
SCOTT@book> select * from t;
ID V1 V2
---------- ---------- ----------
1
2
SCOTT@book> insert into t values (3);
insert into t values (3)
*
ERROR at line 1:
ORA-00947: not enough values
--//增加了字段.
SCOTT@book> insert into t values (3,'a','b');
1 row created.
SCOTT@book> select * from t;
ID V1 V2
---------- ---------- ----------
1
2
3 a b
4.如果enable table lock,如果有会话事务没有提交,在别的会话增加一列一定会挂起:
--//感觉oracle的设计还真奇怪....
--//session 1:
SCOTT@book> alter table t enable table lock;
Table altered.
--//session 2:
SCOTT@book> insert into t values (4,'a','b');
1 row created.
--//session 1:
SCOTT@book> alter table t add v3 varchar2(10);
--//挂起!!
SCOTT@book> @ viewlock
SID SERIAL# USERNAME OSUSER MACHINE MODULE LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2 OWNER OBJECT_TYP OBJECT_NAME BLOCK LOCKWAIT
------ ---------- ---------- ---------- ---------- ------------ --------------- ---------- ---------- ---------- ---------- ------ ---------- -------------------- ----- --------------------
1 10297 SCOTT oracle gxqyydg4 SQL*Plus TM DML(TM) Row-X (SX) None 42044813 0 SCOTT TABLE T No
1 10297 SCOTT oracle gxqyydg4 SQL*Plus TX Transaction Exclusive None 655379 4583660 Yes
30 535 SCOTT oracle gxqyydg4 SQL*Plus TX Transaction None Share 655379 4583660 No 0000000085439E00
30 535 SCOTT oracle gxqyydg4 SQL*Plus TM DML(TM) Row-X (SX) None 42044813 0 SCOTT TABLE T No 0000000085439E00
30 535 SCOTT oracle gxqyydg4 SQL*Plus TX Transaction Exclusive None 589849 212173 No 0000000085439E00
5.viewlock.sql脚本:
$ cat viewlock.sql
column sid format 99999
column username format a10
column osuser format a10
column machine format a10
column lock_type format a15
column mode_held format a10
column mode_requested format a10
column lock_id1 format a10
column lock_id2 format a10
column owner format a6
column object_type format a10
column object_name format a20
column block format a5
column lockwait format a20
SELECT se.SID, se.serial#,se.username, se.osuser, se.machine,se.module,
DECODE (lk.TYPE, 'TX', 'TX Transaction', 'TM', 'TM DML(TM)', 'UL', 'PL/SQL User Lock', lk.TYPE) lock_type,
DECODE (lk.lmode,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
TO_CHAR (lk.lmode)
) mode_held,
DECODE (lk.request,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
TO_CHAR (lk.request)
) mode_requested,
TO_CHAR (lk.id1) lock_id1, TO_CHAR (lk.id2) lock_id2, ob.owner, ob.object_type, ob.object_name,
DECODE (lk.BLOCK, 0, 'No', 1, 'Yes', 2, 'Global') BLOCK, se.lockwait
FROM v$lock lk, dba_objects ob, v$session se
WHERE lk.TYPE IN ('TX','TM', 'UL') AND lk.SID = se.SID AND lk.id1 = ob.object_id(+) order by 1;
[20190522]DISABLE TABLE LOCK.txt的更多相关文章
- [20190524]DISABLE TABLE LOCK(12c).txt
[20190524]DISABLE TABLE LOCK(12c).txt --//如果禁止table lock时,一些ddl操作会被禁止.但是我有点吃惊的是增加字段不受限制.--//链接:http: ...
- disable table 失败的处理
相信每一个维护hbase集群的运维人员一定碰到过disable失败,陷入无穷的"Region has been PENDING_CLOSE for too long..."状态,此 ...
- PLSQL_Oracle Table Lock表级锁的处理(案例)
20150506 Created By BaoXinjian
- 使用 xtrabackup 进行MySQL数据库物理备份
0. xtrabackup的功能 能实现的功能: 非阻塞备份innodb等事务引擎数据库. 备份myisam表会阻塞(需要锁). 支持全备.增量备份.压缩备份. 快速增量备份(xtradb,原理类似于 ...
- 【锁】Oracle锁系列
[锁]Oracle锁系列 1 BLOG文档结构图 2 前言部分 2.1 导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ...
- Microsoft SQL Server Trace Flags
Complete list of Microsoft SQL Server trace flags (585 trace flags) REMEMBER: Be extremely careful w ...
- MySQL Backup--Xtrabackup备份设置锁等待问题
问题描述 innobackupex备份过程需要保证备份数据一致性,通过刷新表缓存和加全局读锁(FLUSH TABLES WITH READ LOCK)获取备份位点,而为防止锁等待超时,会先设置: SE ...
- SQL Server Lock Escalation - 锁升级
Articles Locking in Microsoft SQL Server (Part 12 – Lock Escalation) http://dba.stackexchange.com/qu ...
- [20190415]11g下那些latch是共享的.txt
[20190415]11g下那些latch是共享的.txt http://andreynikolaev.wordpress.com/2010/11/23/shared-latches-by-oracl ...
随机推荐
- git合并多次commit提交
在开发项目工程中经常会遇到为了一个需求产生多次提交记录.有些是可以接受的,比如按照功能点不同进行的提交.但往往会存在这种,只为了一个小东西进行改动,比如多余文件的提交.书写不规范而不得不提交的情况.多 ...
- iOS事件传递和事件响应者链 20170810
一.事件响应者链 事件传递和事件响应链 区别 事件的传递和响应的区别: 事件的传递是从上到下(父控件到子控件),事件的响应是从下到上(顺着响应者链条向上传递:子控件到父控件. 引出 当我们手指触摸屏幕 ...
- 使用 TSPITR 恢复删除的表空间的步骤 (Doc ID 1277795.1)
Steps To Recover A Dropped Tablespace Using TSPITR (Doc ID 1277795.1) APPLIES TO: Oracle Database - ...
- ssh免密登录配置后,登陆失败问题
本文转自博主:_Lance 本文转自:https://blog.csdn.net/qq_19648191/article/details/54845440 相关资料http://blog.csdn.n ...
- CodeForces - 1230C(思维/暴力)
题意 https://vjudge.net/problem/CodeForces-1230C 给了你总共有21张多米诺骨牌,每张牌有两个面,然后给你一个无向图,保证没有环和一个顶点多条边的情况存在.现 ...
- Paper慢慢读 - AB实验人群定向 Learning Triggers for Heterogeneous Treatment Effects
这篇论文是在 Recursive Partitioning for Heterogeneous Casual Effects 的基础上加入了两个新元素: Trigger:对不同群体的treatment ...
- 算法问题实战策略 NTHLON
地址 https://algospot.com/judge/problem/read/NTHLON #include <iostream> #include <vector> ...
- Go module的两个代理源和设置方法
Go module的两个代理源 阿里云 https://mirrors.aliyun.com/goproxy/ 使用帮助 1.使用go1.11以上版本并开启go module机制 2.导出GOPROX ...
- antd配置config-overrides.js文件
下载antd 包 npm install antd 下载依赖包(定义组件按需求打包) npm install react-app-rewired customize-cra babel-plugin- ...
- 网络传播模型Python代码实现
SI模型 import numpy as np import matplotlib.pyplot as plt import smallworld as sw #邻接矩阵 a = sw.a # 感染率 ...