作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我看到这条消息:
IntegrityError: null value in column "date" violates not-null constraint
DETAIL: Failing row contains (10005, null, f, TEST, MAIL).
有没有办法从 PostgreSQL 获取更详细的错误消息?
我缺少表名。
最佳答案
psql
可以使用 VERBOSITY
选项做到这一点:
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 中引入的。但是,我不知道其他客户端如何使用它。
或者,这可以在不设置 VERBOSITY
的情况下通过使用元命令 \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 级别上实现的,因此理论上可以在任何程序中使用它。
关于postgresql - Postgres : More verbose error message: I am missing the table name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41959752/
我是一名优秀的程序员,十分优秀!