DB2 临时表:不存储或不检索信息
我是一个 MSSQL 人员,但我正在处理一个 DB2 查询,该查询需要创建一个临时表,插入其中,并用它做一些事情。 作为一个大大缩短的测试,我使用以下查询,它提供相同的结果。
declare global temporary table tt_testingSyntax (id int);
insert into session.tt_testingSyntax (id) values (1);
insert into session.tt_testingSyntax (id) values (2);
insert into session.tt_testingSyntax (id) values (3);
insert into session.tt_testingSyntax (id) values (4);
select * from session.tt_testingSyntax;
返回零行。 为什么会这样呢? 我已经创建了表空间并验证了该表在整个查询的范围内。
I'm an MSSQL guy, but I'm working on a DB2 query that needs to create a temp table, insert into it, and do stuff with it. As a much-shortened test, I'm using the following query, which is providing the same result..
declare global temporary table tt_testingSyntax (id int);
insert into session.tt_testingSyntax (id) values (1);
insert into session.tt_testingSyntax (id) values (2);
insert into session.tt_testingSyntax (id) values (3);
insert into session.tt_testingSyntax (id) values (4);
select * from session.tt_testingSyntax;
Zero rows are returned. Why would that be? I've created the tablespace and verified the table is in scope throughout the query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
有两个选项...ON COMMIT DELETE ROWS(默认)或ON COMMIT PRESERVE ROWS。
Try:
There are two options...ON COMMIT DELETE ROWS (the default) or ON COMMIT PRESERVE ROWS.
我最终在不知不觉中获得了创建自己的表的权限(即对于用户 X,我可以创建 X.temp1)。 由于该查询只需运行一次,因此效果很好。 谢谢。
I ended up unknowingly having access to create my own tables (i.e. for user X, I could create X.temp1). Since this query need only be run once, this works fine. Thanks.