资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

如何锁住oracle的表 oracle锁表怎么处理

oracle表在什么情况下会被锁住

在对指定表做append操作,其他再做truncate时候,会产生锁表,如下验证步骤,

望江网站建设公司创新互联公司,望江网站设计制作,有大型网站制作公司丰富经验。已为望江上1000家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的望江做网站的公司定做!

1、创建测试表,

create table test_lock(id number, value varchar2(200));

2、执行append语句;并且不做提交,insert /*+append*/ into test_lock values(1,1);

3、再次执行清表语句,truncate table test_lock;报锁表错误,

4、查看锁表语句,发现被锁表,

select b.object_name, t.*

from v$locked_object t, user_objects b

where t.object_id = b.object_id

oracle 锁表的语句

锁表:LOCK TABLE tablename IN 锁模式 MODE;

解锁:commit或rollback;

锁模式有以下几种:

ROW SHARE

ROW SHARE permits concurrent access to the locked table but prohibits users from locking the entire table for exclusive access. ROW SHARE is synonymous with SHARE UPDATE, which is included for compatibility with earlier versions of Oracle Database.

ROW EXCLUSIVE

ROW EXCLUSIVE is the same as ROW SHARE, but it also prohibits locking in SHARE mode. ROW EXCLUSIVE locks are automatically obtained when updating, inserting, or deleting.

SHARE UPDATE

See ROW SHARE.

SHARE

SHARE permits concurrent queries but prohibits updates to the locked table.

SHARE ROW EXCLUSIVE

SHARE ROW EXCLUSIVE is used to look at a whole table and to allow others to look at rows in the table but to prohibit others from locking the table in SHARE mode or from updating rows.

EXCLUSIVE

EXCLUSIVE permits queries on the locked table but prohibits any other activity on it.

怎样在oracle 给表加锁??

lock table 表名 exclusive mode nowait; -- 锁整个表

select * from 表名 where XXX for update nowaitl -- 锁符合条件的记录


网站名称:如何锁住oracle的表 oracle锁表怎么处理
浏览路径:http://cdkjz.cn/article/hjehdh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220