Chinaunix首页 | 论坛 | 博客
  • 博客访问: 58213
  • 博文数量: 22
  • 博客积分: 45
  • 博客等级: 民兵
  • 技术积分: 230
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-16 16:44
文章分类

全部博文(22)

文章存档

2014年(14)

2012年(1)

我的朋友

分类: Oracle

2014-05-20 20:25:17

临时表

1.临时表上的操作比永久表快
1)临时表大部分情况下,数据存放在会话的PGA内;即使数据量过大,需要存放至临时表空间中,I/O速度也比永久表空间的I/O快,因为临时表空间的读写为磁盘读写,不经过缓存。
2)针对临时表的DML不生成重做数据。

2.创建(创建后所有会话均可使用)
create global temporary table tmp_emps on commit preserve rows as select * from employees where 1=2;
注:on commit delete/preserve rows 提交后是否保留数据

3.插入(插入数据提交仅本会话可见)
insert into tmp_emps select * from employees where department_id=30;
commit;

4.删除临时表(必须所有会话都未使用临时表,否则报错ora 14452)
drop table tmp_emps;
阅读(1733) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~