Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是否总是必须删除然后创建一个数据库才能从 pg_dump 文件中恢复它?如果我不删除数据库,即使某些寄存器已经在数据库中,正在恢复的数据也会添加到数据库中的当前数据中(因此数据是重复的)。
您可以在运行 pg_dump 时使用 -c (--clean) 选项,因此转储将包含正确的 DROP ... 命令。
但总的来说,我建议走“硬路”:
dropdb ... createdb ... psql -d ... -f dump.file
通过这种方式,您可以确定数据库中以前的任何内容都没有“剩余”。