You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让pg_dump生成可执行的标准SQL脚本?

问题:pg_dump导出脚本含COPY语句无法直接执行,报错COPY from stdin failed

问题场景

使用pg_dump导出OHDSI数据库中webapi模式下所有表的脚本,初始命令为:

pg_dump --dbname=postgresql://postgres:ohdsi@127.0.0.1:5432/OHDSI -t webapi.* > webapi.sql

生成的脚本包含COPY语句,直接执行时触发错误:

ERROR: COPY from stdin failed: COPY commands are only supported using the CopyManager API.

解决方法

给pg_dump添加--inserts参数,该参数会让导出的脚本生成标准的INSERT语句替代COPY命令,使脚本可直接作为标准SQL执行。

最终执行命令:

pg_dump --inserts --dbname=postgresql://postgres:ohdsi@127.0.0.1:5432/OHDSI -t webapi.* > webapi.sql

内容的提问来源于stack exchange,提问作者John

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 05:10:31