When does Global Temporary table destroy in sql server? -
When does Global Temporary table destroy in sql server? -
i confused usage of global temporary table. have created global temporary table
//session 52 : creator session
create table ##temp(i int) insert ##temp(i) values(1),(2),(3) select * ##temp
//session 56
select * ##temp
//session 57 : lastly session holds refference of ##temp
select * ##temp
now if close session 52, ##temp table destroys.
i believe global temp table released in next cases
it's explicitly removed sessions the creator session closed , there no other sessions referencing session.i confused sessions referencing session(creator session) mean ?
from create table
:
global temporary tables automatically dropped when session created table ends , other tasks have stopped referencing them. association between task , table maintained life of single transact-sql statement. means global temporary table dropped @ completion of lastly transact-sql statement actively referencing table when creating session ended
although personal nit-pick, i'd have used after
instead of when
in lastly sentence.
so, per example, session 57 keeps global temporary table around long it's executing statement relies upon table. statement finish - session has moved onto statement or it's sitting idle - global temp table dropped.
sql-server
Comments
Post a Comment