对于临时表,我们发现它们与连接相关。我的意思是,在一个连接中创建的表仅适用于该连接,并在连接丢失或损坏时自动删除。
SQL Server 中的连接和 session 有什么区别?
最佳答案
连接是物理通信 channel , session 是信息交换的状态。一个连接可以有多个 session 。
The connection is the physical communication channel between SQL Server and the application: the TCP socket, the named pipe, the shared memory region. The session in SQL Server corresponds to the Wikipedia definition of a session: a semi-permanent container of state for an information exchange. In other words the sessions stores settings like cache of your login information, current transaction isolation level, session level
SET
values etc etc.Normally there is one session on each connection, but there could be multiple session on a single connection (Multiple Active Result Sets, MARS) and there are sessions that have no connection (SSB activated procedures, system sessions). There are also connections w/o sessions, namely connections used for non-TDS purposes, like database mirroring
sys.dm_db_mirroring_connections
or Service Broker connectionssys.dm_broker_connections
.
我从 here 得到了答案
关于sql - SQL Server 中 session 和连接的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39199173/