设为首页 加入收藏

TOP

oracle temporary table
2017-10-11 13:09:30 】 浏览:6653
Tags:oracle temporary table

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 后面。

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL Base 下一篇Oracle中用户和模式的区别

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目