title: How to rename a table along with projections in Vertica?
body: <p>I have to alter many columns in a Vertica table, and decided to drop the table altogether and create a new one. I also need 'undo' scripts ready to revert back the changes if needed (using mybatis migrations).</p>
  
  <p>This is my plan:</p>
  
  <pre><code>rename mytable to mytable_backup
  
  create mytable
  create projection mytable_super (as select from mytable)
  
  
  --undo
  drop mytable if exists
  rename mytable_backup to mytable
  </code></pre>
  
  <p>The original mytable was also created with a projection. The above script gives an error saying projection already exists.</p>
  
  <pre><code> DBCException: SQL Error [4482] [42710]: [Vertica][VJDBC](4482) ROLLBACK:         Projection with base name "mytable_super" already exists
  </code></pre>
  
  <p>I believe when I rename the original table, the underlying projection is not being renamed.</p>
  
  <p>What is the best way to rename a table with projections in vertica? Or what is the best way to back up a table and revert back?</p>