快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

oracle如何给表上锁,oracle锁表怎么处理

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 锁表、解锁的语句

一些ORACLE中的进程被杀掉后,状态被置为"killed",但是锁定的资源很长时间不释放,有时实在没办法,只好重启数据库。现在提供一种方法解决这种问题,那就是在ORACLE中杀不掉的,在OS一级再杀。

1.下面的语句用来查询哪些对象被锁:

select object_name,machine,s.sid,s.serial#

from v$locked_object l,dba_objects o ,v$session s

where l.object_id = o.object_id and l.session_id=s.sid;

2.下面的语句用来杀死一个进程:

alter system kill session '24,111'; (其中24,111分别是上面查询出的sid,serial#)

【注】以上两步,可以通过Oracle的管理控制台来执行。

3.如果利用上面的命令杀死一个进程后,进程状态被置为"killed",但是锁定的资源很长时间没有被释放,那么可以在os一级再杀死相应的进程(线程),首先执行下面的语句获得进程(线程)号:

select spid, osuser, s.program

from v$session s,v$process p

where s.paddr=p.addr and s.sid=24 (24是上面的sid)

4.在OS上杀死这个进程(线程):

1)在unix上,用root身份执行命令:

#kill -9 12345(即第3步查询出的spid)

2)在windows(unix也适用)用orakill杀死线程,orakill是oracle提供的一个可执行命令,语法为:

orakill sid thread

其中:

sid:表示要杀死的进程属于的实例名

thread:是要杀掉的线程号,即第3步查询出的spid。

例:c:orakill orcl 12345

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

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

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 表名 exclusive mode nowait; -- 锁整个表

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


本文题目:oracle如何给表上锁,oracle锁表怎么处理
浏览路径:http://6mz.cn/article/dsiioec.html

其他资讯