oralce 有两种临时表  a.会话级临时表  b.事物级临时表

A.事物级临时表

语法

create  global temporary table table_name(

col1  type1,

col2  type2,

................) 

on commit delete rows;

eg

1.create global temporary table transaction_temp_tb

(

col1  varchar2(50)

) on commit delete rows;

2.insert into transaction_temp_tb values('demo');

3.select  *  from transaction_temp_tb;

4.commit;

当commit或者rollback后数据就删除了,但是表结构还在。

5.drop table transaction_temp_tb;

B.会话级临时表

语法

create global temporary table talbe_name(

col1 type1,

...........

) on commit preserve rows;

eg

1.create global temporary table session_temp_tb(

col1 varchar2(50)

) on commit preserve rows;

2.insert into session_temp_tb values('test');

3.commit;

4.select * from session_temp_tb;

5.当commit或者rollback后数据还在,再开一个cmd窗口查询时查询不到数据。

6.删除表要先退出会话在删除。

note:

事物级和会话级的临时表区别在于on commit 后面。

 

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!