首页 > 应用开发 > IT综合 > Temporary Tables (167)

Temporary Tables (167)

原创 IT综合 作者:tsinglee 时间:2007-11-09 09:56:18 0 删除 编辑

In addition to permanent tables, Oracle can create temporary tables to hold
session-private data that exists only for the duration of a transaction or session.

The CREATE GLOBAL TEMPORARY TABLE statement creates a temporary table that can
be transaction-specific or session-specific. For transaction-specific temporary tables,
data exists for the duration of the transaction. For session-specific temporary tables,
data exists for the duration of the session. Data in a temporary table is private to the
session. Each session can only see and modify its own data. DML locks are not
acquired on the data of the temporary tables. The LOCK statement has no effect on a
temporary table, because each session has its own private data.

A TRUNCATE statement issued on a session-specific temporary table truncates data in
its own session. It does not truncate the data of other sessions that are using the same

DML statements on temporary tables do not generate redo logs for the data changes.
However, undo logs for the data and redo logs for the undo logs are generated. Data
from the temporary table is automatically dropped in the case of session termination,
either when the user logs off or when the session terminates abnormally such as
during a session or instance failure.

You can create indexes for temporary tables using the CREATE INDEX statement.
Indexes created on temporary tables are also temporary, and the data in the index has
the same session or transaction scope as the data in the temporary table.

You can create views that access both temporary and permanent tables. You can also
create triggers on temporary tables.

Oracle utilities can export and import the definition of a temporary table. However, no
data rows are exported even if you use the ROWS clause. Similarly, you can replicate
the definition of a temporary table, but you cannot replicate its data.

1. 可创建基于会话或者事务的临时表 .
2. dml锁对于临时表是不需要的 , 因为每个会话都有术语自己的私有数据
3. truncate会话临时表只是将自己会话的数据清楚 , 操作相同的表的其他会话不受影响
4. inshi表中的dml不产生重做日志 , 但是回滚日志和基于回滚日志的重做日志还是会生成
5. 在临时表中可以创建索引
6. 可以为临时表和永久表创建视图 , 也可以在临时表上创建触发器
7. Oracle提供的工具可以导出/导入临时表的定义,但无法导出其中的数据,即使使用 ROWS 子句也是无效的 .


来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

上一篇: Nested Tables (166)
请登录后发表评论 登录
  • 博文量
  • 访问量