How to update column with null value
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Updating a column with NULL in SQL is simple once you remember one rule: NULL is a special marker, not a quoted string. To set a column to null, use SET column_name = NULL. To target rows that already contain null, use WHERE column_name IS NULL, not = NULL.
Set A Column To NULL
If you want to overwrite a column value with null, use an ordinary UPDATE statement.
This sets middle_name to the SQL null marker for the selected row.
The key point is that NULL is unquoted. This is correct:
This is wrong if your intent is a real null:
The quoted version stores the literal text NULL, not a missing value marker.
Update Rows That Currently Have NULL
Sometimes the goal is the reverse: replace missing values with a real value.
Notice the condition uses IS NULL, not = NULL.
That is one of SQL's most important null rules.
Why = NULL Does Not Work
In SQL, null means "unknown" or "missing," so comparisons involving null do not behave like ordinary value comparisons.
This returns no useful match logic:
Correct null checks are:
- '
IS NULL' - '
IS NOT NULL'
That rule applies in SELECT, UPDATE, and DELETE statements.
Update Multiple Columns
You can update several columns in one statement, mixing null assignments and regular values.
This is common when resetting part of a workflow state.
Parameterized Queries In Application Code
If you are updating to null from application code, use parameters rather than building SQL strings manually.
Example in Python with SQLite:
Passing None through the database driver maps cleanly to SQL NULL in many Python DB APIs. Other languages and drivers offer equivalent parameter binding.
Watch Out For NOT NULL Constraints
A column cannot be updated to null if the schema forbids nulls.
Example:
Trying to do this:
will fail because the schema rejects null for that column.
Before updating to null, confirm the column definition actually allows it.
NULL In Expressions
If you are filling or transforming values, functions such as COALESCE can help.
This does not set a column to null. It uses null-aware logic to replace missing values with another expression.
That distinction is useful when you are cleaning data rather than blanking it out.
Common Pitfalls
- Writing
'NULL'instead ofNULLand storing text instead of a null marker. - Using
= NULLinstead ofIS NULLin theWHEREclause. - Trying to set a
NOT NULLcolumn to null. - Forgetting that application-level
None,null, ornilvalues should be sent as parameters, not string-concatenated into SQL. - Assuming null behaves like an empty string or zero in comparisons.
Summary
- Set a column to null with
SET column_name = NULL. - Find null values with
IS NULL, not= NULL. - Do not quote
NULLunless you literally want the textNULLstored. - Check schema constraints before assigning null.
- Use parameterized queries from application code when passing null values into SQL.
Related reading
- How to update if exists otherwise insert new document?
- How to update master table while updating materialized view
- How to update multiple items in a DynamoDB table at once
- How to update SQLAlchemy row entry?
- How to update the _id of one MongoDB Document?
- How to update values using pymongo?
- How to upgrade AWS RDS Aurora MySQL 5.6 to 5.7
- How to upload and retrieve file in mongodb in spring boot application without using GridFSTemplate?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.