sql - SQL Server 中 session 和连接的区别

标签 sql sql-server database session database-connection

对于临时表,我们发现它们与连接相关。我的意思是,在一个连接中创建的表仅适用于该连接,并在连接丢失或损坏时自动删除。

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 connections sys.dm_broker_connections.

我从 here 得到了答案

关于sql - SQL Server 中 session 和连接的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39199173/

相关文章:

php - 性能问题(缓存)- 更快地从数据库进行计算或存储它们

MySQL GROUP BY - 返回错误的日期

mysql - 关于日期时间类型值的问题

SQL 嵌套查询

mysql - 仅当所有状态为 "no"时,如何通过 request_id 选择请求?

SQL Server PIVOT 功能

sql - 类似于 MySQL FIELD() 函数的 MS SQL Server 功能是什么?

php - Yii - 如何从另一个模型获取数据

Python unicode编码问题

c# - 保存本地数据库的最简单方法