postgres 批量更新内容

在程序中遇到这样的需求, 数据库表格式如下

需要把批量更新status, 如name = fox 时, status = 1, name = boa 时,status = 2 .... 类似的

postgres 的写法如下:

update 表名 set status = case name 
        when 'dodo' then '1'  
        when 'eel' then '1' 
       end 
     where name in('dodo', 'eel');
        

  

原文地址:https://www.cnblogs.com/missmzt/p/6022514.html