如何终止连接到我的 oracle 数据库的所有会话?

2023-10-09数据库问题
5

本文介绍了如何终止连接到我的 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 数据库的所有会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

按天分组的 SQL 查询
SQL query to group by day(按天分组的 SQL 查询)...
2024-04-16 数据库问题
77

在 Group By 查询中包含缺失的月份
Include missing months in Group By query(在 Group By 查询中包含缺失的月份)...
2024-04-16 数据库问题
12

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

MySQL GROUP BY DateTime +/- 3 秒
MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)...
2024-04-16 数据库问题
14

按日期分组的 MySQL 累计总和
MySQL cumulative sum grouped by date(按日期分组的 MySQL 累计总和)...
2024-04-16 数据库问题
44