开发者社区 问答 正文

请问on conflict 可以多个 条件 执行不同的更新操作吗 这样写貌似不行 create

请问on conflict 可以多个 条件 执行不同的更新操作吗

这样写貌似不行

create table test(id int primary key, info text, crt_time timestamp);

insert into test values (1,'hello ',now()) on conflict (id) do update set info=excluded.info||'_conf1',crt_time=excluded.crt_time where excluded.id=1 update set info=excluded.info||'_conf2',crt_time=excluded.crt_time where excluded.id=2 ;

展开
收起
云上静思 2022-09-29 13:42:13 1236 发布于北京 分享
分享
版权
来自: PG中文社区技术圈 举报
1 条回答
写回答
取消 提交回答
  • update部分可以用case when试试。

    此答案了来自钉钉群“PG|POLARDB技术进阶”

    2022-09-29 21:11:28 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等