oracle全局临时表
我创建了全局临时表。当我将代码作为单独的脚本执行时,它工作正常。但是当我在 TOAD 中将其作为单个脚本执行时,没有创建任何记录。只有一个空的全局临时表。
例如。
CREATE GLOBAL TEMPORARY TABLE TEMP_TRAN
(
COL1 NUMBER(9),
COL2 VARCHAR2(30),
COL3 DATE
) ON COMMIT PRESERVE ROWS
/
INSERT INTO TEMP_TRAN VALUES(1,'D',sysdate);
/
INSERT INTO TEMP_TRAN VALUES(2,'I',sysdate);
/
INSERT INTO TEMP_TRAN VALUES(3,'s',sysdate);
/
COMMIT;
当我运行上面的代码时,一次运行一个语句,效果很好。但是当我将它作为脚本执行时,它运行良好,但临时表中没有记录。
有人可以帮我吗?
I created the global temp table. when I execute the code as an individual scripts it works fine. but when I execute it as a single script in TOAD then no record was created. there was just an empty global temp table.
eg.
CREATE GLOBAL TEMPORARY TABLE TEMP_TRAN
(
COL1 NUMBER(9),
COL2 VARCHAR2(30),
COL3 DATE
) ON COMMIT PRESERVE ROWS
/
INSERT INTO TEMP_TRAN VALUES(1,'D',sysdate);
/
INSERT INTO TEMP_TRAN VALUES(2,'I',sysdate);
/
INSERT INTO TEMP_TRAN VALUES(3,'s',sysdate);
/
COMMIT;
When I run the above code one statement at a time it works fine. But when I execute it as a script it runs fine but there was no records in temp table.
can anyone help me on this please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您明确声明了
ON COMMIT PRESERVE ROWS
,行似乎“消失”的唯一原因是 TOAD 正在使用多个会话(即您正在使用会话 A 执行脚本并查询会话 B 的表——会看到一个空表)。我不太使用 Toad,但我知道您可以使用此工具打开多个独立会话。
如果您在提交后立即将查询 SELECT * FROM TEMP_TRAN; 放在脚本末尾,会发生什么情况?
since you explicitly stated
ON COMMIT PRESERVE ROWS
, the only reason why the rows would seem to "disappear" is that TOAD is using more than one session (i.e. you're executing the script with Session A and querying the table with Session B -- which would see an empty table).I don't use Toad much, but I know you can open several independent sessions with this tool.
What happens if you put the query
SELECT * FROM TEMP_TRAN;
at the end of your script immediately after the commit ?有时,您需要刷新 Toad 中的数据显示,以便它显示“数据”选项卡下表格中的更改。
Sometimes, you will need to refresh the data display within Toad so that it shows the changes within the table under the tabpage Data.