Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PSQL Drop database with FORCE

I'm trying to drop a database with force, but I get the following ERROR: syntax error at or near "WITH"

postgres=# DROP DATABASE IF EXISTS my_database WITH (FORCE);
ERROR:  syntax error at or near "WITH"
LINE 1: DROP DATABASE IF EXISTS my_database WITH (FORCE);

I'm using Postgres 10.

What could cause this error?

UPDATE

Migrating the db to a new v16 cluster and changing it's port to the default 5432 did the trick.

like image 463
Arno van Oordt Avatar asked Oct 22 '25 04:10

Arno van Oordt


2 Answers

I had a similar issue (syntax error at or near "force"). I then realized that the parenthesis around force are mandatory.

like image 181
Kiruahxh Avatar answered Oct 23 '25 16:10

Kiruahxh


query that worked for me.

DROP DATABASE <DB_NAME> WITH (FORCE);
like image 36
Hiren Timbadiya Avatar answered Oct 23 '25 17:10

Hiren Timbadiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!