小编Kyl*_*yle的帖子

无法将“ON CONFLICT”与 postgres 可更新视图和部分索引一起使用

我有一个可更新的视图,指向具有部分索引的基础表。它看起来像这样

CREATE TABLE if not exists foo (
    a INT,
    b INT,
    x INT,
    y INT,
    z BOOLEAN,
    CONSTRAINT x_or_y CHECK (
      (z and x is not null and y is null)
      or 
      (not z and x is null and y is not null)
    )
);
CREATE UNIQUE INDEX ux ON foo (x, a) WHERE z=TRUE;
CREATE UNIQUE INDEX uy ON foo (y, a) WHERE z=FALSE;
CREATE OR REPLACE VIEW  foo_view AS 
    SELECT * FROM foo;
Run Code Online (Sandbox Code Playgroud)

也就是说,对于每一行,如果为 true,y则必须为 …

postgresql view upsert

5
推荐指数
1
解决办法
875
查看次数

标签 统计

postgresql ×1

upsert ×1

view ×1