SQL
Database Management
Data Manipulation
Null Values
Column Update

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.

Practice system design

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.

sql
UPDATE employees
SET middle_name = NULL
WHERE employee_id = 42;

This sets middle_name to the SQL null marker for the selected row.

The key point is that NULL is unquoted. This is correct:

sql
SET middle_name = NULL

This is wrong if your intent is a real null:

sql
SET middle_name = '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.

sql
UPDATE employees
SET middle_name = 'N/A'
WHERE middle_name IS NULL;

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:

sql
WHERE middle_name = NULL

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.

sql
1UPDATE orders
2SET shipped_at = NULL,
3    status = 'pending'
4WHERE order_id = 1001;

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:

python
1import sqlite3
2
3conn = sqlite3.connect(":memory:")
4cur = conn.cursor()
5cur.execute("CREATE TABLE users (id INTEGER, nickname TEXT)")
6cur.execute("INSERT INTO users VALUES (1, 'neo')")
7
8cur.execute("UPDATE users SET nickname = ? WHERE id = ?", (None, 1))
9conn.commit()
10
11cur.execute("SELECT id, nickname FROM users")
12print(cur.fetchall())

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:

sql
1CREATE TABLE users (
2    id INT PRIMARY KEY,
3    email VARCHAR(255) NOT NULL
4);

Trying to do this:

sql
UPDATE users SET email = NULL WHERE id = 1;

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.

sql
UPDATE products
SET display_name = COALESCE(display_name, name)
WHERE display_name IS NULL;

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 of NULL and storing text instead of a null marker.
  • Using = NULL instead of IS NULL in the WHERE clause.
  • Trying to set a NOT NULL column to null.
  • Forgetting that application-level None, null, or nil values 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 NULL unless you literally want the text NULL stored.
  • Check schema constraints before assigning null.
  • Use parameterized queries from application code when passing null values into SQL.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track 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.

Practice system design

All Rights Reserved.