Welcome 微信登录

首页 / 数据库 / MySQL / Oracle 行级锁与表级锁

一、行级锁:
(下面这句将给该表的所有行都加上锁)
select * from person for update; 如果该行记录已经被锁定,就不用等待,系统会直接抛错 ora-00054
select * from person  where id = "1"  for update nowait 如果该行记录已经被锁定,更新的时候等待5秒,如果这5秒内,该行记录被解锁,那么返回查询结果,如果5秒内仍未解锁,那么系统会直接抛错 ora-00054
select * from person for update wait 5; 另外,如果使用 select * from person  where id = "1"  for update ,当该行记录已经被锁定时,那么系统将一直等待该行记录被释放后,再加锁。 二、表级锁: 行共享:允许用户进行任何操作,禁止排他锁
lock table person in row share mode; 行排他:允许用户进行任何操作,禁止共享锁
lock table person in row exclusive mode; 共享锁:其他用户只能看,不能修改
lock table person in share mode; 共享行排他:比共享锁有更多限制
lock table person in share row exclusive mode; 排他锁:其他用户只能看,不能修改,不能加其他锁
lock table person in exclusive mode; 对于通过lock table命令主动添加的锁定来说,如果要释放它们,只需要发出rollback命令即可。 Linux下Oracle 10g 安装环境配置修复 MySQL页面正常 数据库文件sql乱码相关资讯      Oracle基础教程 
  • Oracle块编程返回结果集详解  (11/10/2013 10:45:58)
  • Oracle基础教程之设置系统全局区  (08/22/2013 14:24:00)
  • Oracle基础教程知识点总结  (06/18/2013 07:43:32)
  • Oracle基础教程之tkprof程序详解  (10/22/2013 11:49:50)
  • Oracle基础教程之sqlplus汉字乱码  (07/18/2013 16:30:00)
  • Oracle 管理之 Linux 网络基础  (02/16/2013 18:37:35)
本文评论 查看全部评论 (0)
表情: 姓名: 字数