临时表分为事物级临时表和会话级临时表,只在临时表中有数据时才会给其分配空间
创建事物级临时表 提交事物后数据被清除释放表空间,默认的是创建此方式
create global temporary table tb
(id number primary key,
name varchar2(20))
on commit delete rows;
会话级临时表,与会话断开后数据被清除释放表空间
create global temporary table tb
(id number primary key,
name varchar2(20))
on commit preserve rows;
也可以使用如下方式创建临时表,可用与复制表结构
create global temporary table tb as select *from emp;