SQL Temporary Table Issue(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 PRESERVE ROWS选项"https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0053719.html" rel="nofollow noreferrer">创建全局临时表 声明.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 临时表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL 临时表问题
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01