title: DECLARE GLOBAL TEMPORARY TABLE Vs CREATE GLOBAL TEMPORARY TABLE in DB2
body: <p>am creating a <code>GLOBAL TEMPORARY TABLE</code> in DB2. and when i surfed i got a two way to create 
  1. Declare 
  2. Create.</p>
  
  <pre><code>1. DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP_EMP
        (EMPNO  CHAR(6) NOT NULL,
         SALARY DECIMAL(9, 2),
         BONUS  DECIMAL(9, 2),
         COMM   DECIMAL(9, 2)) WITH REPLACE ON COMMIT PRESERVE ROWS ;
  
  2. CREATE GLOBAL TEMPORARY TABLE TMPDEPT
        (TMPDEPTNO   CHAR(3)      NOT NULL,
         TMPDEPTNAME VARCHAR(36)  NOT NULL,
         TMPMGRNO    CHAR(6),
         TMPLOCATION CHAR(16) ) ON COMMIT PRESERVE ROWS ;
  </code></pre>
  
  <p>and from IBM site i got a info that create is the best since its being persistent , allowing all user sessions to access the same table definition without having to declare it at startup and many more advantages. </p>
  
  <p>Link : <a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-0912globaltemptable/" rel="noreferrer">http://www.ibm.com/developerworks/data/library/techarticle/dm-0912globaltemptable/</a></p>
  
  <p>and i had few queries in using create over declare: </p>
  
  <ol>
  <li><p>I couldn't find the <code>Replace</code> keyword while using <code>CREATE GLOBAL TEMPORARY TABLE</code> .</p></li>
  <li><p>consider one scenario, 
  am opening a connection and executing a Stored Procedure,<br>
  within that Stored Procedure am creating Global temp table 
  and with in that Stored Procedure am calling Another Stored Procedure 
  which again have <code>same</code> Create Temp table statement .. what will happen in this case.. 
  does it throw any error since both table naes are same and within the single connection? </p></li>
  <li><p>Declare have session and create doesn't have?? does this related to persistant?? </p></li>
  <li><p>in performace wise which is better? Declare temp or create temp? </p></li>
  <li><p>Suggest some scenarioes for the best usage of declare / create !!</p></li>
  </ol>