Do I always have to delete and then create a database to restore it from a pg_dump file? If I don't delete the database, the data being restore is added to the current data in the DB even if some register already are in the database (so the data is duplicated).
+3
A:
You can use -c (--clean) option while running pg_dump, so the dump will contain proper DROP ... commands.
But generally, I would suggest to go the "hard way":
dropdb ...
createdb ...
psql -d ... -f dump.file
In this way you are sure that there are no "left overs" from whatever was previously in the database.
depesz
2009-03-26 17:02:00
Another good thing about your solution is that you do not need to make a VACUUM FULL to reclaim the space of deleted records.
bortzmeyer
2009-03-29 19:41:47