DROP DATABASE is a very special command that cannot be undone. To my knowledge there is no way to drop a database inside a transaction. I quote the manual:
DROP DATABASE cannot be executed inside a transaction block.
Whenever you run two commands in a script in pgAdmin, they are automatically wrapped into a transaction. You can explicitly begin and commit transactions, but you cannot send multiple commands at once in one session and "outside" of a transaction.
Similar in psql when called with
-c command, per documentation:
If the command string contains multiple SQL commands, they are
processed in a single transaction, unless there are explicit
COMMIT commands included in the string to divide it into
However, when fed to psql via standard input:
This is different from the behavior when the
same string is fed to psql's standard input [...]
[...] either using echo as illustrated above, or via a shell here-document, for example:
SELECT * FROM foo;
So you can use psql with standard input in default autocommit-on mode.
Else, you can only run this as a separate command or wrapped into a
COMMIT block separately.
You could use the program
dropdb 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 - which are not SQL. Those are interpreted by psql and not sent to the database engine. You cannot mix meta-commands and SQL. (Well, there are tricks with the the separator meta-command
\\, there is an example in the manual ...)