title: What is the lifecycle of a Oracle SQL session?
body: <p>I came across the concept of global temporary tables in Oracle SQL server. According to a <a href="https://oracle-base.com/articles/misc/temporary-tables" rel="noreferrer">tutorial on global temporary tables</a>:</p>
  
  <blockquote>
    <p>The data in a global temporary table is private, such that data
    inserted by a session can only be accessed by that session.</p>
  </blockquote>
  
  <p>I believe this could allow for the following scenario: a client starts a stored procedure twice, filling up a global temporary table beforehand each time with data for the sp to process. The two computations don't interfere with each other, since each sees only its own data, as opposed to sharing data, as would be the case with a regular table.</p>
  
  <p>However, it all depends on what constitutes a <em>session</em>, and when one starts and ends.</p>
  
  <p>According to the <a href="https://docs.oracle.com/cd/E28271_01/server.1111/e25789/glossary.htm#CBAHEBIG" rel="noreferrer">Oracle Database Concepts Glossary</a>:</p>
  
  <blockquote>
    <p><strong>Session:</strong> A logical entity in the database instance memory that represents the state of a current user login to a database. A single
    connection can have 0, 1, or more sessions established on it.</p>
    
    <p><strong>Connection:</strong> Communication pathway between a client process and an Oracle database instance.</p>
  </blockquote>
  
  <p>This didn't clear up all of my confusion, so here's my concrete question:</p>
  
  <p>My application maintains a single connection to an Oracle SQL server throughout its lifetime. It executes multiple SQL commands/queries on that same connection consecutively, will each of these queries be its own session, will they share a session, or is it not that simply answered?</p>
  
  <p>Consider this pseudo code:</p>
  
  <pre><code>Command c1 = new Command("insert into TMP_TABLE (FOO) values ('TEST')");
  Command c2 = new Command("select FOO from TMP_TABLE");
  
  c1.Execute();
  foreach (var value in c2.Query().Select("FOO"))
  {
      print(value);
  }
  </code></pre>
  
  <p>I have run the above in my application, and as expected, the command <code>c2</code> returned zero results. I take this to mean that each query constitutes its own session, which is what I'm looking for. But can I rely on that?</p>