检查临时表是否存在
如何检查 Oracle 临时表是否存在?当我知道该表存在时,在查询 ALL_TABLES 或 USER_TABLES 时看不到该表。
另外,为了确保我理解临时表,如果使用 ON COMMIT DELETE ROWS 创建,该表将始终存在,但会话结束时数据将被删除?会话是指连接关闭的时间吗?
How do I check to see if an Oracle temporary table exists? I do not see the table when querying ALL_TABLES or USER_TABLES when I know it exists.
Also, to make sure I understand temporary tables, if created with ON COMMIT DELETE ROWS, the table will always exist, but the data will be deleted when the session ends? Is a session referring to when a connection is closed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您拥有临时表,则该临时表将列在
USER_TABLES
中;如果您拥有该表的权限,则该临时表将列在ALL_TABLES
中。如果数据库中存在,它将列在DBA_TABLES
中,但您可能没有查询DBA_TABLES
的权限。如果该表存在于数据库中但不在 ALL_TABLES 中,则意味着当前用户没有临时表的权限。是的,临时表将始终存在(当然,一旦创建)。当您指定
ON COMMIT DELETE ROWS
时,临时表中的数据将在事务完成(提交或回滚)时删除。每个会话始终只能看到它已插入表中的数据,但是当您指定 ON COMMIT DELETE ROWS 时,您将进一步限制数据存在于当前事务中的时间。A temporary table will be listed in
USER_TABLES
if you own it and inALL_TABLES
if you have privileges on the table. It will be listed inDBA_TABLES
if it exists in the database but you may not have privileges to queryDBA_TABLES
. If the table exists in the database but it is not inALL_TABLES
, that implies that the current user does not have privileges on the temporary table.Yes, a temporary table will always exist (once it is created, of course). When you specify
ON COMMIT DELETE ROWS
, the data in the temporary table will be removed when the transaction completes (either committing or rolling back). Each session will always only see the data that it has inserted into the table but when you specifyON COMMIT DELETE ROWS
you're further limiting the time that the data exists to the current transaction.