怎樣在查詢記錄時給記錄加鎖?

  • 系統環境:
      1、操作系統:Windows 2000
      2、數據庫: Oracle 8i R2 (8.1.6) for NT 企業版
      3、安裝路徑:C:\ORACLE
  • 實現方法:
      利用SELECT的FOR UPDATE子句實現conn system/manager --創建實驗用戶 grant connect,resource to test identified by test; conn test/test --創建實驗表1 create table a(a number); insert into a values(1); commit; select * from a for update; 或 select * from a for update of a.a;(a表的a列) --新打開一個SQL*Plus窗口 conn test/test(test用戶上的第二個會話) delete from a; 此時,系統停頓狀態,等待解鎖, 只要在第一個窗口發出roll;或commit;命令,即可解除鎖定狀態。