05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

162<br />

CHAPTER 5 ■ ORACLE PROCESSES<br />

statistics. If SQL*Plus used a single session to report on the number of I/Os performed, how<br />

many bytes were transferred over the network, <strong>and</strong> how many sorts happened, then the<br />

queries used to find these details would be adding to the statistics themselves. They could be<br />

sorting, performing I/O, transferring data over the network (one would assume they would!),<br />

<strong>and</strong> so on. Hence, we need to use another session to measure correctly.<br />

So far, we’ve seen a connection with one or two sessions. Now we’d like to use SQL*Plus to<br />

see a connection with no session. That one is pretty easy. In the same SQL*Plus window used<br />

in the previous example, simply type the “misleading” comm<strong>and</strong>, DISCONNECT:<br />

ops$tkyte@ORA10G> disconnect<br />

Disconnected from <strong>Oracle</strong> <strong>Database</strong> 10g Enterprise Edition Release 10.1.0.3.0 –<br />

Production<br />

With the Partitioning, OLAP <strong>and</strong> Data Mining options<br />

ops$tkyte@ORA10G><br />

Technically, that comm<strong>and</strong> should be called DESTROY_ALL_SESSIONS instead of DISCONNECT,<br />

since we haven’t really disconnected physically.<br />

■Note The true disconnect in SQL*Plus is “exit,” as you would have to exit to completely destroy the<br />

connection.<br />

We have, however, closed all of our sessions. If we open another session using some other<br />

user account <strong>and</strong> query (replacing OPS$TKYTE with your account name, of course),<br />

sys@ORA10G> select * from v$session where username = 'OPS$TKYTE';<br />

no rows selected<br />

we can see that we have no sessions—but we still have a process, a physical connection (using<br />

the previous ADDR value):<br />

sys@ORA10G> select username, program<br />

2 from v$process<br />

3 where addr = hextoraw('AE4CF614');<br />

USERNAME PROGRAM<br />

--------------- ------------------------------------------------<br />

tkyte<br />

oracle@localhost.localdomain (TNS V1-V3)<br />

So, here we have a “connection” with no sessions associated with it. We can use the also<br />

misnamed SQL*Plus CONNECT comm<strong>and</strong> to create a new session in this existing process (the<br />

CONNECT comm<strong>and</strong> might be better named CREATE_SESSION):<br />

ops$tkyte@ORA10G> connect /<br />

Connected.<br />

ops$tkyte@ORA10G> select username, sid, serial#, server, paddr, status<br />

2 from v$session

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!