【创建用户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