title: Truncating all tables in a Postgres database
body: <p>I regularly need to delete all the data from my PostgreSQL database before a rebuild. How would I do this directly in SQL?</p>
  
  <p>At the moment I've managed to come up with a SQL statement that returns all the commands I need to execute: </p>
  
  <pre><code>SELECT 'TRUNCATE TABLE ' ||  tablename || ';' FROM pg_tables WHERE tableowner='MYUSER';
  </code></pre>
  
  <p>But I can't see a way to execute them programmatically once I have them.</p>