删除 SQL Server 中的全局临时表 (##tempTable) [英] Deleting Global Temporary Tables (##tempTable) in SQL Server

查看:39
本文介绍了删除 SQL Server 中的全局临时表 (##tempTable)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL 服务器是否会在给定的不活动时间后自动清除这些内容,或者我是否需要担心自动清除它们?如果是这样,我如何查询要清除的表列表?

Does SQL server automatically purge these out after a given length of inactivity or do I need to worry about purging them automatically? If so, how do I query for a list of tables to purge?

推荐答案

当您关闭与 SQL Server 的连接时,本地临时表将被破坏.正常情况下不需要手动清除它们.如果您维护持久连接或连接池,您可能希望养成使用后立即删除临时表的习惯.

Local temporary tables are destroyed when you close your connection to SQL Server. There is no need to manually purge them under normal circumstances. If you maintain a persistent connection, or connection pooling, you may want to get in the habit of dropping temporary tables immediately after use.

另一方面,由于全局临时表对给定数据库中的所有用户可见,因此会与引用它们的最后一个连接一起销毁.

Global temporary tables, on the other hand, since they are visible to all users in a given database, are destroyed along with the last connection which references them.

这篇关于删除 SQL Server 中的全局临时表 (##tempTable)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆