I am trying to figure out how to drop multiple databases on PostgreSQL in one sql script. I preferrablypreferably need it to work both when executed in pgAdminpgAdmin
console, and when used in psqlpsql
command line tool. When I do:
DROP DATABASE db1;
DROP DATABASE db2;
DROP DATABASE db1;
DROP DATABASE db2;
I get following error:
DROP DATABASE cannot be executed from a function or multi-command string
DROP DATABASE cannot be executed from a function or multi-command string
Is there any way around this problem? I.e., is there any way to run each command separately (like when using "GO" statement on MSSQL), or some other sensible way to easily drop multiple databases? I need this functionality for maintenance scripts during development.