Sql 红移表中的更新
我对红移的表格有一个非常奇怪的问题,下面是我采取的步骤:Sql 红移表中的更新,sql,sql-update,amazon-redshift,Sql,Sql Update,Amazon 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
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
1:Alter table\u name add columns标志整数
/*表\u名称行数10000*/
2:更新表\u名称集
标志=1
where/*某些条件*/
-----受影响的行数为4000
3.更新表\u名称集
标志=0
国旗1在哪里
----受影响的行数为0
当我从表_name中选择flag=1时,我得到4000,那么为什么remaing 6000没有得到更新?
有人能解释这背后的逻辑吗?谢谢你的帮助 因为
标志
也可以是null
,要与null
进行比较,您需要is
运算符(或某些DB引擎提供的null save不等运算符)
更新表\u名称
设置标志=0
其中标志为null或标志1
因为标志
也可以是null
,要与null
进行比较,您需要is
运算符(或某些DB引擎提供的null save不等运算符)
更新表\u名称
设置标志=0
其中标志为null或标志1
update table_name
set flag = 0
where flag is null or flag <> 1