首页 > 解决方案 > 用字符串中的空白替换电子邮件 || 红移

问题描述

我们在 redshift 中有一个表,还有一个包含电子邮件地址的列。如何用空白替换电子邮件地址?

标签: sqlstringsql-updateamazon-redshift

解决方案


您似乎想要一个简单的update声明:

update mytable set emailid = null

这将设置emailidnull表的所有行。null如果该列已经存在很多行,则where子句可能会加快速度:

update mytable set emailid = null where emailid is not null

如果要将值设置为空字符串而不是null

update mytable set emailid = '' where email is not null and email <> ''

请注意,最后一条语句必须emailid是字符串数据类型。


推荐阅读