title: Insert into h2 table if not exists
body: <p>I am using H2. I want to insert a value into a table if it does not exist. I create the table with:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS $types 
    (type VARCHAR(15) NOT NULL UNIQUE);
  </code></pre>
  
  <p>And I want to do something like </p>
  
  <pre><code>REPLACE INTO types (type) values ('type1');
  </code></pre>
  
  <p>I found <a href="http://bogdan.org.ua/2007/10/18/mysql-insert-if-not-exists-syntax.html" rel="noreferrer">an example</a> about Replace that apparently works for MySQL but I am using h2.  But I get an error when I run this from my h2 console:</p>
  
  <pre><code>Syntax error in SQL statement "REPLACE[*] INTO TYPES (TYPE) VALUES ('expense') "; expected "ROLLBACK, REVOKE, RUNSCRIPT, RELEASE, {"; SQL statement:
  REPLACE INTO types (type) values ('expense') [42001-170] 42001/42001
  </code></pre>
  
  <p>I also tried </p>
  
  <pre><code>INSERT IGNORE INTO types (type) values ('expense');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>INSERT INTO types (type) values ('expense') ON DUPLICATE KEY UPDATE type=type;
  </code></pre>
  
  <p>I don't care if the new insert overwrites the old data or if it just does not perform the new insert. Is there a way to do this with h2 database?</p>