Postgres:更详细的错误消息:我缺少表名 [英] Postgres: More verbose error message: I am missing the table name
本文介绍了Postgres:更详细的错误消息:我缺少表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到此消息:
IntegrityError: null value in column "date" violates not-null constraint
DETAIL: Failing row contains (10005, null, f, TEST, MAIL).
是否可以从PostgreSQL获取更详细的错误消息?
Is there a way to get a more verbose error message from PostgreSQL?
我缺少表名。
推荐答案
psql
可以使用 VERBOSITY
选项做到这一点:
psql
can do that using the VERBOSITY
option:
psql (9.6.1)
Type "help" for help.
postgres> \set VERBOSITY verbose
postgres> insert into foobar (data) values ('x');
ERROR: 23502: null value in column "id" violates not-null constraint
DETAIL: Failing row contains (null, x).
SCHEMA NAME: public
TABLE NAME: foobar
COLUMN NAME: id
LOCATION: ExecConstraints, execMain.c:1732
postgres>
此功能在9.6中引入。但是,我不知道该如何从其他客户端使用。
This was introduced in 9.6. However, I don't know how this can be used from other clients.
或者,无需设置 VERBOSITY
使用meta命令 \erverbirose
Alternatively this can be obtained without setting VERBOSITY
by using the meta command \errverbose
postgres> insert into foobar (data) values ('x');
ERROR: null value in column "id" violates not-null constraint
DETAIL: Failing row contains (null, x).
postgres> \errverbose
ERROR: 23502: null value in column "id" violates not-null constraint
DETAIL: Failing row contains (null, x).
SCHEMA NAME: public
TABLE NAME: foobar
COLUMN NAME: id
LOCATION: ExecConstraints, execMain.c:1732
postgres>
这显然是在libpq级别实现的,因此理论上可以在任何程序中使用。
This is apparently implemented on libpq level so it could theoretically be used from any program.
这篇关于Postgres:更详细的错误消息:我缺少表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文