全局临时表 - Global Temprary Table

会话
create global temporary table session_temp_tab on commit preserve rows as select * from dba_users where 1=2;

事务
create global temporary table transaction_temp_tab on commit delete rows as select * from dba_users where 1=2;


select count(1) from session_temp_tab;

select count(1) from transaction_temp_tab;

全局临时表 - Global Temprary Table

insert into session_temp_tab select * from dba_users; 

insert into transaction_temp_tab select * from dba_users;


select count(1) from session_temp_tab;

select count(1) from transaction_temp_tab;

commmit;

select count(1) from session_temp_tab;

select count(1) from transaction_temp_tab;

全局临时表 - Global Temprary Table
当commit之后事务级临时表中的数据自动清除,所以再次查询的时候得到结果为0 !!!

disconnnect;
exit;
dba
select count(1) from session_temp_tab;

全局临时表 - Global Temprary Table
当断开之后重新连接之后,会话级临时表中的数据也被自动删除了!!!

上一篇:使用PTONLNE改MYSQL分区表


下一篇:记github上搭建独立域名的免费博客的方法过程