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

前端之家收集整理的这篇文章主要介绍了sql – #temptable和## TempTable之间的区别?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
你可以在MSsql服务器中解释#temptable和## TempTable之间的区别.我google了,但不能.

请帮我解决这个问题@H_403_3@

解决方法

本地临时表

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.@H_403_3@

例:@H_403_3@

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

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

全球临时表@H_403_3@

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.@H_403_3@

例:@H_403_3@

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

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

Vignesh你可以更多地了解这个@L_301_1@@H_403_3@

猜你在找的MsSQL相关文章