且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

表中所有记录的一列的设置值

更新时间:2023-11-26 22:31:40

UPDATE your_table SET likes = NULL

,或者如果您的likes列不允许NULL:

or if your likes column does not allow NULL:

UPDATE your_table SET likes = ''

默认情况下,某些用于执行数据库查询的SQL工具阻止对所有记录(没有where子句的查询)进行更新.您可以配置它并删除该保存设置,也可以为所有记录添加一个true子句,并像这样进行全部更新:

Some SQL tools that are used for executing DB queries prevent updates on ALL records (queries without a where clause) by default. You can configure that and remove that savety setting or you can add a where clause that is true for all records and update all anyway like this:

UPDATE your_table 
SET likes = NULL
WHERE 1 = 1

如果您与进行比较,那么您还需要IS运算符.示例:

If you compare with NULL then you also need the IS operator. Example:

UPDATE your_table 
SET likes = NULL
WHERE likes IS NOT NULL

因为与相同运算符(=)进行比较 NULL会返回 UNKNOWN .但是IS运算符可以处理NULL.

because comparing NULL with the equal operator (=) returns UNKNOWN. But the IS operator can handle NULL.