我已经进行了备份并pg_dumpall > test.out
成功生成了 test.out,因此备份已完成。
我已使用命令 psql -f test.out postgres进行恢复但在恢复备份时出现以下错误:
databases already exists
relation "products" already exists
duplicate key value violates unique constraint "products_pkey"
Run Code Online (Sandbox Code Playgroud)
我实际上想用备份替换现有数据库中的数据。怎么做?
问题是您尝试恢复的数据库已经存在。
您可以运行一个DROP DATABASE database_name命令来删除现有数据库,然后可以运行 test.out 文件。
或者您可以运行pgdumpall --clean > test.out然后运行生成的文件。clean 标志将使生成的文件中包含 DROP DATABASE 命令。
| 归档时间: |
|
| 查看次数: |
14886 次 |
| 最近记录: |