本文回顧數據庫中connection和session的區別:
A connection is a physical communication pathway between a client process and a database instance.
A session is a logical entity that exists in the database instance. It is your session state, or a collection of data structures in memory that represents your unique session. It is what would come first to most people’s minds when thinking of a “database connection.” It is your session in the server, where you execute SQL, commit transactions, and run stored procedures.
對比如下:
A connection may have zero, one, or more sessions established on it. Each session is separate and independent,even though they all share the same physical connection to the database. A commit in one session does not affect any other session on that connection. In fact, each session using that connection could use different user identities!
connection 是指物理上的連接,建立了連接後才能開始會話(session),一個connetion上可以有多個session,也可以沒有session。