The difference between connecting to and participating in Oracle __oracle

Source: Internet
Author: User
Tags data structures sessions dedicated server

1.oracle Chinese Concept Manual

Both the concepts of connection (connection) and sessions (session ) are closely related to the user process , but they have different meanings.

connections : Communication channels between user processes and Oracle instances (communication pathway). This communication channel is via interprocess communication mechanisms (interprocess communication mechanisms) (running user processes and Oracle processes on the same computer) or network software (network Software (when a database application is running on a different computer with an Oracle server, it needs to be communicated over the network).

session : A connection that a user establishes through a user process with an Oracle instance [this connection is different from the connection in the preceding paragraph, which refers primarily to the relationship between the user and the database]. For example, when a user initiates Sql*plus, a valid username and password must be provided, and Oracle then establishes a session for this user. The session persists from the time the user connects to the user's disconnect (or quits the database application).

The same user in an Oracle database can create multiple sessions at the same time. For example, a user name/password Scott/tiger user can connect to the same Oracle instance multiple times.

When the system is not running in Shared services mode, Oracle creates a service process (server processes) for each user session. When the system is running in Shared service mode, multiple user sessions can share the same service process.

2. Through the example understanding (note this strength from http://hi.baidu.com/bystander1983/blog/item/7201a3835d1961ab0cf4d294.html)

There are A/b Two cities, the need to send cabbage from a to B city

Build a road first.
It then transports cabbage to the past, including preparing cabbage and transporting cabbage and returning to a series of movements.

A road that can transport 0-n of cabbage
Of course, there may be more than one road from A to B.
Once a cabbage is transported, a road can only be opened when it is really on the road.
One shipment will not affect the status of other shipments


corresponding database
A represents the client process
b represents the server-side process
Highways represent connections ,
Transport a cabbage to represent a conversation

A connection can be multiple sessions
A session can be not dependent on a connection, not even connected (when I am ready to actually start the shipment and then establish the connection)
One session does not affect other sessions

3 from (http://book.51cto.com/art/200707/51921.htm)

A connection is not a synonym for a session. A connection may have 0, one, or more sessions established on it. Each session is separate and separate, even if they share an identical physical connection to the database. A commit in a session does not affect any other sessions on that connection. In fact, each session that uses the connection can use a different user identity. In Oracle, a connection is a physical line between a client process and a database instance-a network connection. The connection may be a dedicated server process or a scheduling process. A connection can have 0 or more sessions, that is, the presence of a connection does not necessarily accompany the corresponding session. In addition, a session does not necessarily have a connection. A physical connection can be deleted by the client, leaving only one idle session. When a client wants to do something in that session, it needs to re-establish the physical connection.
 Connection: A connection is a physical channel from the client to a database instance. A connection is established either through the network or through the IPC mechanism. The most typical connection is between a client process and a dedicated server or a shared server. However, when using Oracle's Connection Manager (Cman), a connection can be between the client and the Cman or between Cman and the database.
 Session: A session is a logical entity that exists in an instance. It is a collection of memory data structures that represent a unique session, used to execute SQL, commit transactions, and run stored procedures on the server.
In fact, it is very common for a connection to have multiple sessions. Use Sql*plus to describe the differences between the connection and session. Two sessions can be generated when the Autotrace command is used. Two sessions can also be established through a connection that uses a single process. First, perform the following actions.

Sql>select username,sid,serial#,server,paddr,status from
v$session
where Username=user
/
USERNAME SID serial#server paddr STATUS
-------------------------------------------
ops$tkyte 153 3196 DEDI cated ae4cf614 ACTIVE

Where user is a system function, and the result is the users who are currently connected to the database. The current result is a session that connects to a dedicated server individually. The PADDR column is the address of the unique dedicated server process.
Second, open autotrace to view the statistics that execute the statement in Sql*plus.

Sql>set Autotrace on statistics
sql>select username,sid,serial#,server,paddr,status from
v$session
where Username=user
/   

This opens up two sessions, but both use a dedicated server process. The query results show that they all have the same PADDR column value. Therefore, the two sessions use a single process, that is, an individual connection. Note that one of the sessions, the original session (Sql*plus), is in the active (active) state. The session runs the query to display the result information. But another session in the passive State (inactive) is the autotrace session, which is responsible for monitoring the first session and reporting everything that the session did.
When you open Autotrace in Sql*plus, Sql*plus completes the following actions when you perform a DML operation (INSERT, UPDATE, delete, select, and merge).
1 if the second session does not exist, a new session is created using the current connection.
2 The Sql*plus request generates a new session query V$sesstat view, which records the initial statistics for sessions running DML.
3 run the DML operation in the first session.
4 after the DML statement has been completed, Sql*plus will require the other sessions to query the V$sesstat again and produce a difference report showing the execution of the DML session on the statistical data.
If you close Autotrace,sql*plus, the second session is terminated and the V$session view is no longer monitored.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.