2016-07-29 48 views
1

我试图从一个大小约为1.6GB的sql文件插入数据。我用命令:Postgres SQL文件插入挂起

\i filename.sql 

但是它已经运行了十多分钟。最初,当我跑了我输出,如下图所示:

psql:xxx.sql:1102: ERROR: role "xxx" does not exist 
psql:xxx.sql:1124: ERROR: relation "xxx" already exists 
psql:xxx.sql:1127: ERROR: role "xxx" does not exist 
psql:xxx.sql:1138: ERROR: relation "xxx" already exists 
psql:xxx.sql:1141: ERROR: role "xxx" does not exist 
psql:xxx.sql:1177: ERROR: relation "xxx" already exists 
psql:xxx.sql:1180: ERROR: role "xxx" does not exist 
psql:xxx.sql:1191: ERROR: relation "xxx" already exists 
psql:xxx.sql:1194: ERROR: role "xxx" does not exist 
psql:xxx.sql:1223: ERROR: relation "xxx" already exists 
psql:xxx.sql:1226: ERROR: role "xxx" does not exist 
psql:xxx.sql:1237: ERROR: relation "xxx" already exists 
psql:xxx.sql:1240: ERROR: role "xxx" does not exist 

这样继续下去,直到最后的输出是:

psql:xxx.sql:1183266: ERROR: duplicate key value violates unique constraint "xxx" 
DETAIL: Key (id)=(2) already exists. 
CONTEXT: COPY mo_logs, line 1: "2 +6421558671  +15759151518 LolWithPlus  unable to deliver, dropping : undefined method `bytesize' for..." 

然后控制台显示什么新从那时起。在我第一次尝试我认为这是挂这么EXITED但得到了以下的输出:

Cancel request sent 

这使我相信这个脚本仍在运行,但我没有办法告诉。任何人都可以建议我如何诊断正在发生的事情,或者告诉我插件是否失效,如悬挂所示。

回答

1

看起来好像SQL脚本包含几个COPY语句。
其中一个(COPY TO mo_logs)失败,另一个(COPY TO midn_protections)在您中断处理时正在运行。

正常情况下,psql在出错后继续工作,只会执行下一条语句。为了避免这种情况,请使用选项--set ON_ERROR_STOP=on来启动它。

+0

感谢您的意见。当时以为它仍在运行,但能够看到除错误以外的其他日志记录显示正在取得进展,这将是非常好的。这可能吗?试图找到一个命令,但没有运气,除了基本日志被发送到我选择的文件。 – EamonnMcElroy

+0

您可以使用'psql'的'-a'选项让它回显当前语句。 –

+0

所以那就是'\ i filename.sql -a' – EamonnMcElroy