加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql – #temptable和## TempTable之间的区别?

发布时间:2020-12-12 16:28:32 所属栏目:MsSql教程 来源:网络整理
导读:你可以在MSSQL服务器中解释#temptable和## TempTable之间的区别.我google了,但不能. 请帮我解决这个问题 解决方法 本地临时表 Local temp tables are only available to the current connection for the user; and they are automatically deleted when the u
你可以在MSSQL服务器中解释#temptable和## TempTable之间的区别.我google了,但不能.

请帮我解决这个问题

解决方法

本地临时表

Local temp tables are only available to the current connection for the
user; and they are automatically deleted when the user disconnects
from instances. Local temporary table name is stared with hash (“#”)
sign.

例:

CREATE TABLE #LocalTempTable(
UserID int,UserName varchar(50),UserAddress varchar(150))

本地临时表的范围仅与当前用户的当前连接相关.

全球临时表

Global Temporary tables name starts with a double hash (“##”). Once
this table has been created by a connection,like a permanent table it
is then available to any user by any connection. It can only be
deleted once all connections have been closed.

例:

CREATE TABLE ##NewGlobalTempTable(
UserID int,UserAddress varchar(150))

所有SQL Server连接都可以看到全局临时表.当您创建其中之一时,所有用户都可以看到它.

Vignesh你可以更多地了解这个here

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读