postgresql - 是否可以在不使用 pg_restore 的情况下在云 sql 中导入 postgresql 自定义格式转储文件?
问题描述
我从 chembl 数据库下载了 postgresql .dmp 文件。
我想将其导入 gcp cloudsql。
当我使用控制台和 gcloud 命令运行它时,我收到以下错误:
Importing data into Cloud SQL instance...failed.
ERROR: (gcloud.sql.import.sql) [ERROR_RDBMS] exit status 1
The input is a PostgreSQL custom-format dump.
Use the pg_restore command-line client to restore this dump to a database.
我可以在不使用 pg_restore 命令的情况下导入自定义格式的 dmp 文件吗?
https://cloud.google.com/sql/docs/postgres/import-export/importing
该站点上的文档中有对 pg_restore 的描述,但我没有正确理解。
如果是自定义格式的文件,上传到云shell后是否需要pg_restore?
解决方案
根据CloudSQL 文档:
Only plain SQL format is supported by the Cloud SQL Admin API.
The custom format is allowed if the dump file is intended for use with pg_restore.
如果由于某种原因您不能使用pg_restore
,我会启动一个本地 Postgres 实例(即在您的笔记本电脑上)并使用它pg_restore
来恢复数据库。
加载到本地数据库后,您可以使用pg_dump
以明文格式转储到文件,然后使用控制台或gcloud
命令加载到 CloudSQL。
推荐阅读
- sql - 使用 Oracle12 中的合并技术在公用表中插入非重复值
- apache-spark - 使用 Spark Operator 在 Kubernetes 中启用多集群故障转移
- android - 无法连接到 Android 调试数据库,即使更改端口
- javascript - react-router-dom 'Link' 不仅适用于代码的一部分,而且在其他地方也能正常工作。有什么问题?
- c - 编写一个程序来检查给定字符串中每个 ASCII 值的相同字符的数量
- vbscript - VBS,从父子结构创建完整的层次结构字符串,递归
- excel - 用于比较两张纸之间的商店名称和发票编号并突出显示匹配的宏
- c++ - 使用 QNetworkReply 请求 POST 超时
- wordpress - ACF:如果用户不是帖子作者,则在 the_loop() 中未正确检索数据
- python - 变分自动编码器 (VAE) 返回一致的输出