关于dml操作提交之后的一些问题

实验1:
session1在scott下执行了一条select语句select * from DBA_objects;
已经赋予scott dba的权限

session2在sys用户下
SQL> select sid,username,SQL_ID,sql_hash_value from v$session where username<>'SYS' and username is not null;

       SID USERNAME                       SQL_ID        SQL_HASH_VALUE
---------- ------------------------------ ------------- --------------
       159 SCOTT                          6avfua5g1gkh2     1578617346

SQL> select sql_fulltext from v$sqlarea where sql_id='6avfua5g1gkh2';

SQL_FULLTEXT
--------------------------------------------------------------------------------
select * from dba_objects

session1的操作完成之后,session2再次查询,sql_id为null
select sid,username,SQL_ID,sql_hash_value from v$session where username<>'SYS' and username is not null;

       SID USERNAME                       SQL_ID        SQL_HASH_VALUE
---------- ------------------------------ ------------- --------------
       159 SCOTT                                                     0

实验2
session1在scott下执行一条update语句update d set deptno=60 where deptno=20;但没有commit.

session2在sys用户下
SQL> select sid,username,SQL_ID,sql_hash_value from v$session where username<>'SYS' and username is not null;

       SID USERNAME                       SQL_ID        SQL_HASH_VALUE
---------- ------------------------------ ------------- --------------
       159 SCOTT                          1cvcw5h23uqu1       71129921

SQL> select sql_fulltext from v$sqlarea where sql_id='1cvcw5h23uqu1';

SQL_FULLTEXT
--------------------------------------------------------------------------------
update d set deptno=60 where deptno=20

session1执行commit;

session2再次查询
SQL> select sid,username,SQL_ID,sql_hash_value from v$session where username<>'SYS' and username is not null;

       SID USERNAME                       SQL_ID        SQL_HASH_VALUE
---------- ------------------------------ ------------- --------------
       159 SCOTT                          1cvcw5h23uqu1       71129921

commit不是标志事务的结束吗,也说明这个事务已经完成了,但这时sql_id并不为null,这是为什么呢?


标签: 暂无标签
zhaojingyuo

写了 14 篇文章,拥有财富 332,被 3 人关注

转播转播 分享分享 分享淘帖
回复

使用道具

P6 | 发表于 2012-6-22 23:31:43
SQL_ID
        VARCHAR2(13)
         SQL identifier of the SQL statement that is currently being executed

这个SQL_ID和事务没有关系。
回复

使用道具

P4 | 发表于 2012-6-23 00:03:55
老师,我还是不太明白,select结束了,对应sql_id就为null了,update操作已经commit了,为什么sql_id还有对应的值呢,是说update这条sql还没有结束吗?
回复

使用道具

您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

意见
反馈