title: How do Oracle temporary tables exactly work in a stored procedure like this?
body: <p>Suppose I'm using the following Oracle code in a stored procedure:</p>
  
  <pre><code>CREATE GLOBAL TEMPORARY TABLE temp_table (
      field1 NUMBER,
      field2 NUMBER
  )
  ON COMMIT DELETE ROWS
  </code></pre>
  
  <p>This particular stored procedure may be called concurrently by different users at any single moment. As I understand it, the data visible to the user in the temporary table will be private to him or her, and these rows are deleted on a COMMIT.</p>
  
  <p>However, how do the following work with respect to this:</p>
  
  <ol>
  <li><p>Is it safe to call the CREATE statement above <strong>every single time</strong> the stored procedure is called? Would this result in an error cause there already "exists" a temporary table (possibly) created by a different user (/session)? Or would this be OK, since the server treats them privately anyway?</p></li>
  <li><p>What exactly happens with the ON COMMIT DELETE ROWS? I assume that this only deletes the rows specific to the particular user session, leaving the data by other sessions unharmed, correct?</p></li>
  </ol>
  
  <p>Any help would be appreciated. :)</p>