Created
April 15, 2019 17:47
-
-
Save danielmcq/89b127aa8cb51f27d0a487b837a4cf7a to your computer and use it in GitHub Desktop.
Useful Oracle Scripts
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 | |
| sql_id, | |
| COUNT(*) | |
| FROM | |
| ( | |
| SELECT | |
| t.sql_id, | |
| s.sid, | |
| COUNT(*) | |
| FROM | |
| v$sqltext_with_newlines t, | |
| v$session s | |
| WHERE | |
| t.address = s.sql_address | |
| AND t.hash_value = s.sql_hash_value | |
| AND s.username = 'username' | |
| GROUP BY | |
| t.sql_id, | |
| s.sid | |
| ORDER BY | |
| t.sql_id, | |
| s.sid | |
| ) aa | |
| GROUP BY | |
| sql_id; |
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 | |
| ( | |
| SELECT | |
| username | |
| || ' - ' | |
| || osuser | |
| FROM | |
| v$session | |
| WHERE | |
| sid = a.sid | |
| ) blocker, | |
| a.sid | |
| || ', ' | |
| || ( | |
| SELECT | |
| serial# | |
| FROM | |
| v$session | |
| WHERE | |
| sid = a.sid | |
| ) sid_serial, | |
| ' is blocking ', | |
| ( | |
| SELECT | |
| username | |
| || ' - ' | |
| || osuser | |
| FROM | |
| v$session | |
| WHERE | |
| sid = b.sid | |
| ) blockee, | |
| b.sid | |
| || ', ' | |
| || ( | |
| SELECT | |
| serial# | |
| FROM | |
| v$session | |
| WHERE | |
| sid = b.sid | |
| ) sid_serial | |
| FROM | |
| v$lock a, | |
| v$lock b | |
| WHERE | |
| a.block = 1 | |
| AND b.request > 0 | |
| AND a.id1 = b.id1 | |
| AND a.id2 = b.id2; |
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 | |
| s.username, | |
| s.sid, | |
| s.serial#, | |
| s.osuser, | |
| t.sql_id, | |
| sql_text, | |
| status | |
| FROM | |
| v$sqltext_with_newlines t, | |
| v$session s | |
| WHERE | |
| t.address = s.sql_address | |
| AND t.hash_value = s.sql_hash_value | |
| AND s.username = 'username' | |
| ORDER BY | |
| username, | |
| s.sid, | |
| t.piece; |
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
| --ALTER SYSTEM KILL SESSION 'sid,serial#'; | |
| ALTER SYSTEM KILL SESSION '186,7947'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment