psql -d postgres -c "DROP DATABASE appdb WITH (FORCE);"

Category: Databases & SQL

psql -d postgres -c "DROP DATABASE appdb WITH (FORCE);"

Drop a database and its connections

Drops the database and every object and row in it, terminating any remaining connections first thanks to WITH (FORCE), new in PostgreSQL 13. There is no undo, so back up with pg_dump before running it on anything real.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.