Last active
June 30, 2016 01:09
-
-
Save kakari2/aa3446743b4f849b1a5a1c8928a4d28f to your computer and use it in GitHub Desktop.
Oracleでロックを解除する方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 残っているセッションを調査 | |
| select | |
| a.INST_ID, | |
| a.SCHEMANAME, | |
| a.SQL_ID, | |
| a.WAIT_CLASS, | |
| a.EVENT, | |
| -- b.SQL_FULLTEXT, | |
| trunc((sysdate - a.SQL_EXEC_START) * 24 * 60 * 60,2) as "経過", | |
| -- a.WAIT_TIME, | |
| a.PROGRAM, | |
| a.SID, | |
| a.serial#, | |
| substr(b.SQL_TEXT,1, 60) as sql_head | |
| from | |
| gV$SESSION a, | |
| gV$sqlarea b | |
| where 1 = 1 | |
| and status = 'ACTIVE' | |
| and a.INST_ID = b.INST_ID | |
| and a.SQL_ID = b.SQL_ID | |
| order by a.INST_ID,a.SQL_EXEC_START | |
| ; | |
| --上で見つからない場合 | |
| SELECT | |
| object_name, | |
| oracle_username, | |
| s.sid, | |
| s.serial#, | |
| s.logon_time, | |
| sql_address | |
| FROM v$locked_object l, | |
| dba_objects o, | |
| v$session s | |
| WHERE l.OBJECT_ID = o.OBJECT_ID | |
| AND l.SESSION_ID = s.SID | |
| AND object_name = 'foobar' | |
| ; | |
| -- sessionをkill | |
| alter system kill session '65, 3932' | |
| -- HWMをリセットする(大量データのInsert-deleteを繰り返した後などハイウォーターマークが上昇するので) | |
| ALTER TABLE tablefoobar ENABLE ROW MOVEMENT ; | |
| ALTER TABLE tablefoobar SHRINK SPACE; | |
| ALTER TABLE tablefoobar DISABLE ROW MOVEMENT ; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment