SQL: Locking on temp tables
Are locks taken out when querying a temp table? If so, how granular are they by default? Is there a performance hit similar to locking normal rows/table?
I assume no locks are taken because temp tables (at least as of SQL 2008开发者_运维技巧) are created per instance.
select x,y,z into #MyTempTable
from SomeOtherTable
A temp table like this is local to your connection. It can't affect concurrency because no-one else can read it.
Temp tables generally behave like normal tables for concurrency, isolation, locks, transactions etc
You may (or may not!) get tempdb contention (link about TF 1118) under heavy load which isn't the same as table locking
Is your question prompted by one of those SQL Server 6.x myths (DBA.SE)?
精彩评论