不同数据库中临时表的使用说明

Oracle、Mysql临时表:数据只在事务或者会话期间存在,保存临时用到的数据。

分为两种:

一、会话指定的临时表(会话级别)

中断会话时,此临时表才会消失。

create globle temporary table_name(

id int primary key,

name varchar2(30)

)on commit preserve rows;

二、事务指定的临时表(事务级别)

当前事务提交后,临时表消失。

create globle temporary table_name(

id int primary key,

name varchar2(30)

)on commit delete rows;

这里补充一下,事务结束的标志:

1.显示提交::commit

2.隐式提交:执行ddl或者dcl语句

ddl:create drop alter

dcl:grant revoke 等

SQLServer中的临时表:

一、全局临时表

所有的连接,都可以看到此临时表。

当创建临时表的连接断开,并且引用全局临时表的连接全部断开后,此表才会消失。

create table ##table_name(

.........

)

或者

select * into ##table_name from 基本表;

二、局部临时表

只有创建该临时表的连接能引用此表,其他连接不能引用。

创建临时表的连接断开后,此表消失。

create table #table_name(

.........

)

或者

select * into #table_name from 基本表;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值