Oracle全局临时表/PHP交互问题
我从未使用过全局临时表,但是我对它们如何在 php 环境中工作有一些疑问。
数据如何共享:假设使用 oci8 通过 php 持久连接到 oracle。 数据是否与数据库 ID 绑定? 是基于Apache httpd 恶魔来做的吗? 或者每个单独的请求都是独一无二的?
会话的数据什么时候从全局临时表中清除? 我假设(或者更确切地说希望)它在 php 脚本退出时完成。 或者,如果不是,我假设我需要在脚本退出之前将其删除。
I've never used the Global Temporary Tables however I have some questions how they will work in a php environment.
How is data shared: Assuming persistent connections to oracle through php using oci8. Is the data tied to a database id? is it done based on the Apache httpd demons? Or is each individual request unique?
When is the data for the session cleared from the global temporary table? I'm assuming (or rather hoping) that its done when the php script exits. Alternatively if not I'm assuming I'll need to remove it before script exit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
全局临时表只是表结构的逻辑定义(名称、列名、列数据类型等)。 当会话通过插入数据引用它时,会在临时表空间中创建一个数据段来仅保存该会话的数据。 因此,不同的会话可以引用相同的逻辑表定义,因为它们每个都有自己的专用数据段,可以在提交时或会话断开连接时轻松清除这些数据段,而不会影响其他会话。
GTT 中数据的清除可以在提交时进行,也可以在会话结束时进行,具体取决于创建它时使用的选项。 无论哪种情况,您都不必在断开连接之前自行清理。
GTT 的一个有用替代方案是子查询分解子句(“WITH”),您可以在其中创建多个关系,这些关系可以引用先前在该 SQL 语句中声明的关系。 这些可以在超过一定内存使用量时由 Oracle 自动物化为临时表空间中的数据段,也可以使用 MATERIALIZE 优化器提示手动物化。
The global temporary table is simply the logical definition of a table structure (Name, column names, column data types etc). When a session references it by inserting data, a data segment is created in a temporary tablespace to hold only that session's data. Different sessions can therefore reference the same logical table definition because they each have their own dedicated data segment which can be purged easily on commit or when the session disconnects without affecting other sessions.
The purging of the data in the GTT can either be on commit or when the session ends, depending on the option with which it was created. In either case you do not have to attend to the purging yourself before disconnecting.
A useful alternative to the GTT is the subquery factoring clause ("WITH"), in which you can create multiple relations that can reference those previously declared in that SQL statement. These can be materialised as a data segment in a temporary tablespace either automatically by Oracle when they exceed a certain memory usage, or manually by using the MATERIALIZE optimizer hint.
如果我没记错的话,全局临时表中的数据只能从一个活动会话中获得,并且只能用于此活动会话(我的意思是会话=连接)。 因此您只能看到之前在活动会话中插入的数据。 因此我相信,该数据在关闭会话后会被清除。 无论您使用哪种语言。
至少我是这么认为的。 :D
正如这里所写:
http://www.oracle-base.com/articles/8i/TemporaryTables。 php
全局临时表中的数据是私有的,因此会话插入的数据只能由该会话访问。
即使数据库会话异常结束,临时表中的数据也会在数据库会话结束时自动删除。
对不起,我的英语不好。
If I remember correct, the data in global temporary tables is available only from one active session and only for this active session (I mean session = connection). So you can see only data which was inserted before in active session. Therefore I belive, this data is cleared after closing session. No matter which language are you using.
At least I think so. :D
As is it written here:
http://www.oracle-base.com/articles/8i/TemporaryTables.php
The data in a global temporary table is private, such that data inserted by a session can only be accessed by that session.
Data in temporary tables is automatically delete at the end of the database session, even if it ends abnormally.
Sorry for my bad english.