SQL临时表问题 [英] SQL Temporary Table Issue

查看:63
本文介绍了SQL临时表问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个临时表 DETAILS ,并遵循在其中创建和插入的相同语法.但是我没有收到任何结果集.但是, CREATE INSERT 语句成功运行,并且INSERT语句中的Row也受到了影响.但是,当我运行最后一个 SELECT 语句以查看记录时,结果集为空.

I've created a temporary table DETAILS and follow the same syntax of creating and inserting in it. But I have not received any result set However, the CREATE and INSERT statements ran successfully and the Row was also affected in the INSERT statement . But the result set was empty when I ran the last SELECT statement to view the record .

DROP TABLE DETAILS ;
CREATE GLOBAL TEMPORARY TABLE DETAILS AS (
SELECT ins_id , firstname , pages FROM 
INSTRUCTOR)DEFINITION ONLY;

INSERT INTO DETAILS
SELECT ins_id , firstname , pages 
FROM INSTRUCTOR WHERE ins_id = '1';

SELECT * FROM DETAILS ;

推荐答案

如果要在提交后在CGTT中保留行,则必须指定创建全局临时表语句.
ON COMMIT DELETE ROWS 选项否则有效,并且在提交时会清除此类表.

If you want to preserve rows in CGTT after commit, you have to specify ON COMMIT PRESERVE ROWS option of the CREATE GLOBAL TEMPORARY TABLE statement.
ON COMMIT DELETE ROWS option is in effect otherwise, and such a table is cleared on commit.

这篇关于SQL临时表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆