ORA-14450 attempt to access a transactional temp table already in use
Cause: An attempt was made to access a transactional temporary table that has been already populated by a concurrent transaction of the same session.
Action: Do not attempt to access the temporary table until the concurrent transaction has committed or aborted.
一般情况下,ORA-14450在自治事务中出现的多一些,大家在使用自治事务时一定要小心
SQL> create global temporary table temp_toms
2 (
3 str varchar2(64)
4 ) on commit delete rows;
表已创建.
SQL>
SQL> select * from temp_toms;
未选定行
SQL> insert into temp_toms values('1234');
已创建 1 行。
SQL> select * from temp_toms;
STR
--------------------------------
1234
SQL>
SQL> declare
2 pragma autonomous_transaction;
3 begin
4 insert into temp_toms values('other transaction use temp_toms test');
5 commit;
6 end;
7 /
declare
*
第 1 行出现错误:
ORA-14450: 试图访问已经在使用的事务处理临时表
ORA-06512: 在 line 4
SQL> select * from temp_toms;
STR
--------------------------------
1234
SQL>
另外一种情况下,也能出现ORA-14450的错误,测试如下
SQL> select sid from v$mystat where rownum=1;
SID
----------
104
SQL>
SQL> desc temp_toms
名称 是否为空? 类型
----------------------------------------- -------- -----------------
STR VARCHAR2(32)
SQL> insert into temp_toms values('modify structur test');
已创建 1 行。
SQL>
SQL> select * from temp_toms;
STR
--------------------------------
modify structur test
SQL>
此时,在SID=104的session中不做commit/rollback,打开另外一个session,尝试修改临时表结构,
看看会出现什么现象:
C:Documents and Settingsunix>sqlplus study/study
SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 5月 6 12:26:54 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select sid from v$mystat where rownum=1;
SID
----------
90
SQL>
SQL> alter table temp_toms add name varchar2(32);
alter table temp_toms add name varchar2(32)
*
第 1 行出现错误:
ORA-14450: 试图访问已经在使用的事务处理临时表