Created
          September 14, 2016 21:19 
        
      - 
      
- 
        Save ar45/b13f1409becb605bced78dbfe6ead6a6 to your computer and use it in GitHub Desktop. 
    Drop all tables in a schema - postgres
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | DO $$ | |
| DECLARE | |
| stmt TEXT; | |
| BEGIN | |
| FOR stmt IN SELECT 'DROP TABLE IF EXISTS "' || tablename || '" CASCADE;' | |
| from pg_tables | |
| WHERE schemaname = 'public' | |
| LOOP | |
| EXECUTE stmt; | |
| END LOOP; | |
| END; | |
| $$ | |
| ; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment