有没有一种方法可以指定在执行sql脚本时,遇到脚本上的第一个错误时它会停止,无论以前的错误如何,它通常都会继续。
Is there a way to specify that when executing a sql script it stops when encountering the first error on the script, it usually continues, regardless of previous errors.
推荐答案我认为要添加到.psqlrc中的解决方案远非完美
I think the solution to add following to .psqlrc is far from perfection
\set ON_ERROR_STOP on上设置ON_ERROR_STOP
存在更简单方便的方法-将psql与参数一起使用:
there exists much more simple and convenient way - use psql with parameter:
psql -v ON_ERROR_STOP=1最好同时使用 -X 参数来关闭.psqlrc文件的使用。 对我来说很完美
better to use also -X parameter turning off .psqlrc file usage. Works perfectly for me
p.s。在Peter Eisentraut的重要文章中找到了解决方案。谢谢你,彼得! petereisentraut.blogspot/2010/03/ running-sql-scripts-with-psql.html
p.s. the solution found in great post from Peter Eisentraut. Thank you, Peter! petereisentraut.blogspot/2010/03/running-sql-scripts-with-psql.html
更多推荐
遇到错误时如何停止Postgres脚本?
发布评论