Truncate all tables in postgres database
        Posted  
        
            by Aaron
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Aaron
        
        
        
        Published on 2010-05-13T18:04:15Z
        Indexed on 
            2010/05/13
            18:34 UTC
        
        
        Read the original article
        Hit count: 399
        
I regularly need to delete all the data from my postgresql database before a rebuild. How would I do this directly in SQL?
At the moment I've managed to come up with a SQL statement that returns all the commands I need to execute:
SELECT 'TRUNCATE TABLE ' ||  tablename || ';' FROM pg_tables WHERE tableowner='MYUSER';
but I cant see a way to execute them programatically once I have them...
Thanks in advance
© Stack Overflow or respective owner