开发者社区> 问答> 正文

请问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 1157 0
1 条回答
写回答
取消 提交回答
  • update部分可以用case when试试。

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

    2022-09-29 21:11:28
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载