PostgreSQL 将字段为空的值替换为指定值

  1. null 表示缺失的值, ""表示空值
  2. null 参与的表达式运算都返回null
    使用is null 判断是null
    is not null 判断非null
    nullif(value1, value2) 如果value1 == value2 返回null
    coalesce(arg1, arg2, …) 返回第一个 不为null的值

所以可以使用如下语句,实现将table中filed为空的记录替换为指定值:

update table set filed = COALESCE(NULLIF(trim("filed"), ''), 'value')

via:https://blog.csdn.net/huxu981598436/article/details/83114468

猜你喜欢

转载自blog.csdn.net/weixin_41287692/article/details/83787834