- Connect to PostgreSQL server via command line:
psql -d postgre
- At the prompt, type SQL query to construct DROP DATABASE statement then that statement via \gexec meta-command
- Replace
test
with your desired pattern
Some alternative ways :
- Anonymous code block
- Using a shell script
SELECT 'DROP DATABASE ' || quote_ident(datname) || ';'