update emp set comm = 100 where empno = 7369;
使用dba用户查看事务
ADDR XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC STATUS START_TIME START_SCNB START_SCNW START_UEXT START_UBAFIL START_UBABLK START_UBASQN START_UBAREC SES_ADDR FLAG SPACE RECURSIVE NOUNDO PTX NAME PRV_XIDUSN PRV_XIDSLT PRV_XIDSQN PTX_XIDUSN PTX_XIDSLT PTX_XIDSQN DSCN-B DSCN-W USED_UBLK USED_UREC LOG_IO PHY_IO CR_GET CR_CHANGE START_DATE DSCN_BASE DSCN_WRAP START_SCN DEPENDENT_SCN XID PRV_XID PTX_XID CON_ID ---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- -------------------- ---------- ---------- ---------- ------------ ------------ ------------ ------------ ---------------- ---------- ----- --------- ------ --- -------------------------------------------------------------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------- ---------- ---------- ---------- ------------- ---------------- ---------------- ---------------- ---------- 00007FFB1AB14670 10 18 2737 5 1144 472 37 ACTIVE 09/21/19 10:39:55 2830945 0 2 5 1144 472 37 00007FFB204976A0 3587 NO NO NO NO 0 0 0 0 0 0 0 0 1 1 5 0 11 2 2019/9/21 1 0 0 2830945 0 0A001200B10A0000 0000000000000000 0000000000000000 0
查看锁
自动加锁 for uppdate
自动加锁演示
试探是否加锁
select * from employee where deptid = 10 for update nowait; select * from employee where deptid = 10 for update wait 5; select * from employee where deptid = 10 for update skip locked;
杀掉session锁用户
查询锁(select * from v$lock;)找出sid
根据sid找出serial#
select sid, serial# from v$session where sid = 42;
dba用户杀死session
alter system kill session '42,58191';
select * from emp e; update emp set comm = 100 where empno = 7369; rollback; select * from emp e where e.empno = 10 for update; select * from employee where deptid = 10 ; select * from employee where deptid = 10 for update; update employee set salary = 5566 where empid = 1 and deptid = 10;commit; select * from employee where deptid = 10 for update nowait; select * from employee where deptid = 10 for update wait 5; select * from employee where deptid = 10 for update skip locked; select * from v$transaction; select * from v$lock; select sid, serial# from v$session where sid = 42; alter system kill session '42,58191';