具有“提交时删除行”的全局临时表没有保存任何数据
我在创建脚本中定义了一个全局临时表 (GTT),使用提交时删除行的选项。我希望能够让不同的用户在 GTT 中看到自己的数据,而不是其他人会话的数据。这在我们的测试环境中完美运行。
但随后,我将 GTT 部署为客户数据库功能更新的一部分。客户打电话给我,既沮丧又担心,因为 GTT 不再保存任何数据,他们也不知道为什么。
具体来说,如果有人这样做:
insert into my_GTT (description) values ('Happy happy joy joy')
数据库会响应:
1 row inserted.
但是,如果同一个最终用户尝试:
select * from my_GTT
数据库会响应:
0 rows returned.
此问题发生在客户端站点上,我们无法在内部重现它。什么可能导致这种行为?
I have a global temporary table (GTT) defined in a creation script using the option to delete rows on commit. I wanted to be able to have different users see their own data in the GTT and not the data of other people's sessions. This worked perfectly in our test environment.
But then, I deployed GTT as part of an update to functionality to a client's database. The client called me up all upset and worried, because the GTT wasn't holding any data any more, and they didn't know why.
Specifically, if someone did:
insert into my_GTT (description) values ('Happy happy joy joy')
the database would respond:
1 row inserted.
However, if the same end user tried:
select * from my_GTT
The database would respond:
0 rows returned.
This issue is happening on the client site, and we can't reproduce it in house. What could be causing this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为达米安是对的,并且有一个自动提交。我能想到的唯一其他选项是某种连接池问题(即选择是从单独的会话到插入完成的)
I think Damien is right and there is an autocommit. The only other option I can come up with is some sort of connection pool issue (ie the select is being done from a separate session to the insert)
ON COMMIT DELETE ROWS
= 一个事务中的数据ON COMMIT PRESERVE ROWS
= 一个数据库会话中的数据(一个用户有 2 个会话 = 2 个会话 = 不同的内容)如果定义了 GTT使用
ON COMMIT DELETE ROWS
,在任何显式提交或隐式提交之后它将为空(=隐式提交=在任何DLL命令之后,包括例如截断表,更改索引,添加分区,修改列,交换分区):如果 GTT 是用 ON COMMIT PRESERVE ROWS 定义的,它将保留数据直到会话结束:
ON COMMIT DELETE ROWS
= data in one transactionON COMMIT PRESERVE ROWS
= data in one database session (one user with 2 sessions = 2 session = different content)If GTT is defined with
ON COMMIT DELETE ROWS
, it would be empty after any explicit commit or implicit commit (= implicit commit = after any DLL command including for example truncate table, alter index, add partition, modify column, exchange partition):If GTT is defined with
ON COMMIT PRESERVE ROWS
, it would hold data till end of session:您的目标环境中是否打开了某些设置,其中每个语句都是自动提交的?
(我的经验是在 SQL Server 中,这是默认设置,但据我了解,在 Oracle 中,默认设置是保持事务打开,直到显式提交。注意,自 2000 年以来我就没有接触过 Oracle)
Do you have some setting turned on in your target environment where each statement is auto-committing?
(My experience is in SQL Server, where such is the default, but I understand in Oracle, the default is to keep the transaction open until an explicit commit. Mind, I haven't touched Oracle since ~2000)