【问题标题】:copy (pg_dump) .sql file to postgresql using Cygwin使用 Cygwin 将(pg_dump).sql 文件复制到 postgresql
【发布时间】:2018-03-22 17:52:36
【问题描述】:

我已经下载了 YELP 的 sql 文件,并尝试将 sql 导入本地 Postgresql。

我在 Windows 10 上运行 postgres 并使用 Cygwin 执行我在 Google 上找到的命令。 (我花了很长时间才使用 Cygwin 而不是 windows psql shell)

无论如何,Yelp 提供了 sql 中的数据模式以及 sql 中的数据。您可能会在下面找到它们的链接 https://www.yelp.com/dataset/download

所以,基本上我的想法是用 YELP 的模式创建一个空表 然后,将所有 YELP 的数据复制到该表中。

pg_dump -h localhost -p 5433 -U postgres -s mydb < D:/YELP/yelp_schema.sql
pg_dump -h localhost -p 5433 -U postgres -d mydb < D:/YELP/yelp_sql-2.tar

我正在检查我的数据库事务,它什么都没有改变,我也看不到表。

这是我在 Cygwin 终端上看到的 enter image description here

我的 postgresql 数据库上什么也没有

请告诉我我错过了什么。

非常感谢

【问题讨论】:

    标签: postgresql cygwin pg-dump


    【解决方案1】:

    您的链接要求通过电子邮件下载。我怀疑 yelp 对此不透明。所以我没有检查他们是否对他们的数据集有任何建议......无论如何,你使用pg_dump 转储数据。要导入生成的文件,请使用 psql 用于纯 sql 文件,pg_restore 用于自定义格式文件...

    例如:

    psql -h localhost -p 5433 -U postgres -f D:/YELP/yelp_schema.sql
    pg_restore -h localhost -p 5433 -U postgres -s worldmap -Ft D:/YELP/yelp_schema.sql
    

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

    pg_dump — 将 PostgreSQL 数据库提取到脚本文件或其他文件中 存档文件

    【讨论】:

    • 这真的没有帮助。架构文件有 @, ' 我不认为它可以以某种方式读取它。这很奇怪:(
    • 如果你需要帮助,你应该从 sql 文件中发布它失败的确切摘录
    • pg_restore,我收到此错误“pg_restore:命令行参数太多(首先是“-Ft”)尝试“pg_restore --help”以获取更多信息。”
    猜你喜欢
    • 2020-12-04
    • 2012-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-20
    • 2018-07-22
    • 1970-01-01
    相关资源
    最近更新 更多