title: Create table if not exists syntax db2
body: <p>I wish to write a SQL script that will check whether the table/sequence exists or not before create the table/sequence.</p>
  
  <p>I tried Google and get some solution that work for other people but not work for me:</p>
  
  <p>Method 1:</p>
  
  <pre><code>SELECT *
  FROM   tableA
  WHERE  EXISTS
   (SELECT * from tableB);
  </code></pre>
  
  <p>This is work with <code>select</code> statement. Then I try with create table statement:</p>
  
  <pre><code>CREATE TABLE "SMEADM"."JXTEST"  (
            "ACCOUNTSENTRYID" BIGINT NOT NULL  )   
           IN "DATATBSP"
  WHERE  EXISTS
   (SELECT * from tableB);
  </code></pre>
  
  <p>This will hit error <code>42601</code>.</p>
  
  <p>Method 2:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS "SMEADM"."JXTEST"  (
            "ACCOUNTSENTRYID" BIGINT NOT NULL  )   
           IN "DATATBSP" ; 
  </code></pre>
  
  <p>This also bring me to error <code>42601</code>.</p>
  
  <p>Method 3:</p>
  
  <pre><code>begin
    declare continue handler for sqlstate '42710' begin end;
    execute immediate 'CREATE TABLE "SMEADM"."JXTEST"  (
            "ACCOUNTSENTRYID" BIGINT NOT NULL  )   
           IN "DATATBSP"';
  end
  </code></pre>
  
  <p>And this also bring me to error <code>42601</code>.</p>
  
  <p>Kindly advise.</p>