清除postgresql数据库,因为它是新的

tak*_*hin 2 sql database postgresql scripting

我使用创建了PostgreSQL数据库转储psql.

现在我想从文件中恢复此备份:

psql -d thesamename -f /my/backup/file
Run Code Online (Sandbox Code Playgroud)

但是我得到数据已经存在的错误.

是否有任何命令从数据库中删除所有内容以使其处于刚刚创建状态,除了再次删除和创建?
(我不想再次设置所有者,tablescpace等)

也许某种方法用备份文件中的那个覆盖数据库?(备份文件来自另一个数据库服务器)

Ali*_* R. 5

https://www.postgresql.org/docs/current/static/app-pgdump.html

https://www.postgresql.org/docs/current/static/app-pgrestore.html

详细-c了解这些脚本的选项.

  • 哦谢谢.我在`psql`而不是`pg_dump`中查找`--clean`选项 (2认同)