[英]update in redshift table
I have a very weird problem with a table in redshift, below are the steps that I took : 我在redshift中的表格有一个很奇怪的问题,以下是我采取的步骤:
1 : Alter table_name add columns flag integer
/* table_name row count 10000*/
2 :update table_name set
flag = 1
where/* some condition*/
-----rows affected 4000
3.update table_name set
flag = 0
where flag<> 1
----rows affected 0
When I select from table_name where flag = 1 I get 4000 then why the remaing 6000 are not getting updated? 当我从table_name中选择flag = 1时,我得到4000,那么为什么restg 6000没有得到更新? Can anyone explain logic behind this? 谁能解释这个背后的逻辑? Thanks for your help!! 谢谢你的帮助!!
Because flag
can also be null
and to compare with null
you need the is
operator (or a NULL save unequal operator which some DB engines provide) 因为flag
也可以为null
并且要与null
比较,所以需要is
运算符(或某些数据库引擎提供的NULL保存不等于运算符)
update table_name
set flag = 0
where flag is null or flag <> 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.