Reputation: 475
I have example
database in postgres
and there are 2 ways to delete this:
1) DROP DATABASE example
2) DELETE FROM pg_database where datname = 'example'
Which one is right, and what is difference?
Upvotes: 1
Views: 137
Reputation: 246473
The first way is the correct way.
The second statement does not drop the database, but deletes an entry in the metadata catalog table that contains all the databases. Direct updates to catalog tables are forbidden, because (like in this case) they can corrupt system integrity.
Upvotes: 4