//SQL server
在創建表的時候添加了“#”首碼的表,##代表全局臨時表,#代表局域臨時表
select * into ##aaa from personage
select * into #aaa from personage
select * from #aaa
//oracle
临时表用于存放会话或事务的私有数据。建立临时表后,其结构会一直存在,但其数据只在当前事务内或当前会话内有效。
事務臨時表:
事务临时表是指数据只在当前事务内有效的临时表。如果建立临时表时没有指定on commit选项,则默认为事务临时表
會話臨時表:
会话临时表是数据只在当前会话内有效的临时表。建立临时表时,通过使用on commit preserve rows选项,可以指定会话临时表
//例子
create global temporary table tempding(cola int) on commit preserve rows;
insert into tempding values(1248);
select * from tempding;
commit;
//例子生成測試數據
with generator as (select rownum id from all_objects where rownum<=5) select v1.id
from generator v1,generator v2 where v1.id<=1000
在創建表的時候添加了“#”首碼的表,##代表全局臨時表,#代表局域臨時表
select * into ##aaa from personage
select * into #aaa from personage
select * from #aaa
//oracle
临时表用于存放会话或事务的私有数据。建立临时表后,其结构会一直存在,但其数据只在当前事务内或当前会话内有效。
事務臨時表:
事务临时表是指数据只在当前事务内有效的临时表。如果建立临时表时没有指定on commit选项,则默认为事务临时表
會話臨時表:
会话临时表是数据只在当前会话内有效的临时表。建立临时表时,通过使用on commit preserve rows选项,可以指定会话临时表
//例子
create global temporary table tempding(cola int) on commit preserve rows;
insert into tempding values(1248);
select * from tempding;
commit;
//例子生成測試數據
with generator as (select rownum id from all_objects where rownum<=5) select v1.id
from generator v1,generator v2 where v1.id<=1000