title: postgres: syntax error at or near "BEGIN"
body: <p>I read this post <a href="https://stackoverflow.com/questions/167576/check-if-table-exists-in-sql-server">Check if table exists in SQL Server</a></p>
  
  <p>and wrote this script:</p>
  
  <pre><code>do $$
  begin
  
  IF (EXISTS (SELECT *
                   FROM INFORMATION_SCHEMA.TABLES
                   WHERE TABLE_SCHEMA = 'st'
                   AND  TABLE_NAME = 'config_change_log'))
  BEGIN
     CREATE SCHEMA AUTHORIZATION st
     CREATE TABLE st.config_change_log
  (
    id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
    last_config_version varchar(255),
    is_done Boolean,
    chage_description varchar(255)
  )
  
  END
  
  end
  $$
  </code></pre>
  
  <p>however when I run:</p>
  
  <pre><code>psql -h localhost -d myDb -U myUser -f myScript.sql
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>psql:myScript.sql:21: ERROR:  syntax error at or near "BEGIN"
  </code></pre>