How can I kill all sessions connecting to my oracle database?(如何终止连接到我的 oracle 数据库的所有会话?)
问题描述
我需要在没有管理员和管理员监督的情况下快速(并且强制)终止所有连接到我的 oracle 数据库的外部会话.
I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator.
我不想只是锁定数据库并让用户优雅地退出.
I don't want to just lock the database and let the users quit gracefully.
我将如何编写此脚本?
推荐答案
此答案深受以下对话的影响:http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3
This answer is heavily influenced by a conversation here: http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3
ALTER SYSTEM ENABLE RESTRICTED SESSION;
begin
for x in (
select Sid, Serial#, machine, program
from v$session
where
machine <> 'MyDatabaseServerName'
) loop
execute immediate 'Alter System Kill Session '''|| x.Sid
|| ',' || x.Serial# || ''' IMMEDIATE';
end loop;
end;
我跳过终止源自数据库服务器的会话以避免终止 Oracle 与自身的连接.
I skip killing sessions originating on the database server to avoid killing off Oracle's connections to itself.
这篇关于如何终止连接到我的 oracle 数据库的所有会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何终止连接到我的 oracle 数据库的所有会话?


基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01