title: Redshift - Retrieving SQL used to create a view
body: <p>I have mistakenly deleted a table and hence the view that was dependent on it is lost. I am trying to re-create this view but I am not sure what was the SQL used for this.</p>
  
  <p>I have tried the below but each of the these give me partial SQL statement and not the complere SQL used to create the view.</p>
  
  <pre><code>select starttime, type, text from svl_statementtext
  where lower(text) like '%view_name%' order by starttime desc;
  
  
  select query, text
  from stl_querytext
  where pid = pg_backend_pid() and lower(text) like '%view_name%'
  order by query desc;
  </code></pre>