Oracle临时表(即:Oracle 全局临时表)的语法

摘自:

http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_7002.htm#SQLRF01402


例子:
The following statement creates a temporary table today_sales for use by sales representatives in the sample database.
 Each sales representative session can store its own sales data for the day in the table. The temporary data is deleted at the end of the session.

CREATE GLOBAL TEMPORARY TABLE today_sales
   ON COMMIT PRESERVE ROWS    AS SELECT * FROM scott.emp where rownum<2;

 

DELETE ROWS 的含义:
DELETE ROWS 
Specify DELETE ROWS for a transaction-specific temporary table. 
This is the default. Oracle Database will truncate the table (delete all its rows) after each commit.


 

PRESERVE ROWS 的含义
PRESERVE ROWS 
Specify PRESERVE ROWS for a session-specific temporary table. 
Oracle Database will truncate the table (delete all its rows) when you terminate the session.

 

Specify GLOBAL TEMPORARY to indicate that the table is temporary and that its definition is visible to all sessions with appropriate privileges.
The data in a temporary table is visible only to the session that inserts the data into the table.

When you first create a temporary table, its table metadata is stored in the data dictionary, but no space is allocated for table data.
Space is allocated for the table segment at the time of the first DML operation on the table.

The temporary table definition persists in the same way as the definitions of regular tables,
but the table segment and any data the table contains are either session-specific or transaction-specific data.
You specify whether the table segment and data are session- or transaction-specific with the ON COMMIT keywords.

You can perform DDL operations (such as ALTER TABLE, DROP TABLE, CREATE INDEX) on a temporary table only when no session is bound to it.

 A session becomes bound to a temporary table by performing an INSERT operation on the table.
A session becomes unbound to the temporary table by issuing a TRUNCATE statement or at session termination,
or, for a transaction-specific temporary table, by issuing a COMMIT or ROLLBACK statement.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值