查找违反要添加约束的行

问题描述 投票:1回答:1

我正在尝试向表添加检查约束,例如

ALTER TABLE foo ADD CONSTRAINT bar CHECK (...);

我得到错误:

ERROR:  check constraint "bar" is violated by some row
********** Error **********

ERROR: check constraint "bar" is violated by some row
SQL state: 23514

有没有办法让postgres(9.6)告诉我它在哪一行失败?这会很有帮助。

sql postgresql constraints check-constraints
1个回答
0
投票

确定。

Select * from bar where <desired check constraint>;
© www.soinside.com 2019 - 2024. All rights reserved.