【oracle dba】强制关闭会话

【创建用户test1005】

create user test1005 identified by 1234;
grant create session to test1005;
grant create table to test1005;
grant drop any table to test1005;
grant insert any table to test1005;
grant update any table to test1005;
grant all privileges to test1005;

创建完毕后,见用DBA用户luna来关闭test1005的未提交会话。

 

【以用户test1005登录,建表并插入记录,不提交】

复制代码
test1005@ORCL>create table emp1005(
  2      id number(10),
  3      name nvarchar2(20)
  4  );

表已创建。

test1005@ORCL>select * from emp1005;

未选定行

test1005@ORCL>insert into emp1005(id,name) values('1','andy');

已创建 1 行。
复制代码

到这里,表已经创建出来了,但未提交记录。

 

【以管理员登录,强制关闭test1005的会话】

复制代码
luna@ORCL>select sid, serial# from V$session
  2  where sid in (select sid from v$LOCK where TYPE in ('TM','TX'));

       SID    SERIAL#
---------- ----------
       114       1699

已选择 1 行。

luna@ORCL>alter system kill session '114,1699';

系统已更改。
复制代码

核心语句:

select sid, serial# from V$session where sid in (select sid from v$LOCK where TYPE in ('TM','TX'));
alter system kill session '114,1699';

 

【以用户test1005登录,查询表emp1005】

test1005@ORCL>select * from emp1005;
select * from emp1005
*1 行出现错误:
ORA-00028: 您的会话己被终止

果然会话被终止了。

 

【以用户test1005重新登录,查看表emp1005中的记录】

复制代码
test1005@ORCL>conn
请输入用户名:  test1005
输入口令:
已连接。
test1005@ORCL>select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
EMP1005                        TABLE

已选择 1 行。

test1005@ORCL>select * from emp1005;

未选定行

test1005@ORCL>
复制代码

这里说明表emp1005还保持未提交的状态。

 

参考资料:https://www.cnblogs.com/sekihin/p/5033360.html 

END

posted @   逆火狂飙  阅读(381)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
历史上的今天:
2021-10-05 【Mybatis】LambdaQueryWrapper用法示例
2021-10-05 【oracle/语法】With语句的写法
2021-10-05 【oracle】同是选出每个城市最年长女性,not exits 方案和 分析函数rank方案的巨大差距
2021-10-05 【Java/加解密】不算加密的加密-base64加解密(使用Java8的Base64实现)
2019-10-05 [MyBatis]完整MyBatis CRUD工程
2019-10-05 [log4j]Error:The method getLogger(String) in the type Logger is not applicable for the arguments
2019-10-05 [java]将秒数转化为“天时分秒”的格式(转贴+修改)
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东
点击右上角即可分享
微信分享提示