To my knowledge there is no way to drop a database inside a transaction. I quote the [manual][1]: > DROP DATABASE cannot be executed inside a transaction block. It is a very special command that cannot be undone. You can only run this as a separate command. You could use the program [`dropdb`][2] from the shell - or write a shell-script with it that drops multiple database in succession. BTW, the only difference between what you can run from pgAdmin and from `psql` are the [meta-comnmands of psql][3] - which are not SQL. Those are interpreted by psql and not sent to the database. You cannot mix meta-commands and SQL. [1]: http://www.postgresql.org/docs/current/interactive/sql-dropdatabase.html [2]: http://www.postgresql.org/docs/current/interactive/app-dropdb.html [3]: http://www.postgresql.org/docs/current/interactive/app-psql.html#APP-PSQL-META-COMMANDS