ORACLE(3):连接、会话

参考:官方文档

什么是连接、会话和进程

connection(连接):
A connection is a physical communication pathway between a client process and a database instance. A communication pathway is established using available interprocess communication mechanisms or network software. Typically, a connection occurs between a client process and a server process or dispatcher, but it can also occur between a client process and Oracle Connection Manager (CMAN).
用户进程到服务器进程的一个物理通道。
processs(进程):

A process is a mechanism in an operating system that can run a series of steps. The mechanism depends on the operating system. For example, on Linux an Oracle background process is a Linux process. On Windows, an Oracle background process is a thread of execution within a process。
进程是操作系统,对于oracle来说分为客户端进程和服务进程。

session(会话):

A session is a logical entity in the database instance memory that represents the state of a current user login to a database. For example, when a user is authenticated by the database with a password, a session is established for this user. A session lasts from the time the user is authenticated by the database until the time the user disconnects or exits the database application.

会话是实例中存在的一个逻辑结构。这就是你的会话状态,也就是表示特定会话的一组内存 中的数据结构。

连接和会话的关系
1.一个connection 可以有0个会话,1个会话和多个会话:

一个连接0个会话:当数据库没启动,可以连接,但是没有会话。

窗口1查询

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> disconnect
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

disconnect 只是中断了session,连接还在

窗口2:

SQL> select t.USERNAME,t.STATUS,t.SID,t.SERIAL# from v$session t where t.USERNAME= 'STUDY';

no rows selected

SQL> 

2.一个连接一个session

窗口1:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 

窗口2:

SQL> select t.USERNAME,t.STATUS,t.SID,t.SERIAL# from v$session t where t.USERNAME= 'STUDY';

USERNAME										   STATUS			   SID	  SERIAL#
------------------------------------------------------------------------------------------ ------------------------ ---------- ----------
STUDY											   INACTIVE			     8	      269

SQL> 

3.一个连接多个会话

窗口1:

SQL> set autot on
SQL> select 1 from dual;

	 1
----------
	 1

窗口2:

SQL> select t.USERNAME,t.STATUS,t.SID,t.SERIAL# from v$session t where t.USERNAME= 'STUDY';

USERNAME										   STATUS			   SID	  SERIAL#
------------------------------------------------------------------------------------------ ------------------------ ---------- ----------
STUDY											   INACTIVE			     8	      273
STUDY											   INACTIVE			     9	      409

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值