title: PostgreSQL: IF EXISTS COMMENT ON TABLE
body: <p>I am little bit stucked with task IF EXIST.</p>
  
  <p>I have several lines query with the COMMENTS ON TABLE function</p>
  
  <pre><code>COMMENT ON TABLE my_table1 IS 'Comment for table1';
  COMMENT ON TABLE my_table2 IS 'Comment for table2';
  COMMENT ON TABLE my_table3 IS 'Comment for table3';
  COMMENT ON TABLE my_table3 IS 'Comment for table4';
  </code></pre>
  
  <p>I want to do, when I will execute this query, if one of the table doesn't exist query will pass that and continue.</p>
  
  <p>I tried to do that task with IF EXIST action, but it doesn't works like UPDATE or other actions. Where am I wrong?</p>
  
  <pre><code>IF EXISTS (SELECT relname FROM pg_class where relname='my_table1')
  then
  COMMENT ON TABLE my_table1 IS 'Comment for table1';
  IF EXISTS (SELECT relname FROM pg_class where relname='my_table2')
  then
  COMMENT ON TABLE my_table1 IS 'Comment for table2';
  IF EXISTS (SELECT relname FROM pg_class where relname='my_table3')
  then
  COMMENT ON TABLE my_table1 IS 'Comment for table3';
  IF EXISTS (SELECT relname FROM pg_class where relname='my_table4')
  then
  COMMENT ON TABLE my_table1 IS 'Comment for table4';
  </code></pre>