Common SQL Errors

MySQL Error 1566: ER_NULL_IN_VALUES_LESS_THAN - How to Fix and Prevent

Galaxy Team
August 7, 2025

<p>MySQL raises error 1566 when a partition definition uses NULL inside a VALUES LESS THAN clause, which is not permitted.</p>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1566 ER_NULL_IN_VALUES_LESS_THAN?

<p>MySQL Error 1566 ER_NULL_IN_VALUES_LESS_THAN appears when a partition range list contains NULL in the VALUES LESS THAN clause. Replace NULL with MAXVALUE or a concrete constant, or add NOT NULL constraints, to resolve the issue.</p>

Error Highlights

Typical Error Message

Not allowed to use NULL value in VALUES LESS THAN

Error Type

Data Definition Error

Language

MySQL

Symbol

ER_NULL_IN_VALUES_LESS_THAN

Error Code

1566

SQL State

HY000

Explanation

Table of Contents

What does MySQL error 1566 ER_NULL_IN_VALUES_LESS_THAN mean?

MySQL throws error 1566 when you attempt to create or alter a RANGE or LIST partition and specify NULL in the VALUES LESS THAN list. The partitioning engine expects only concrete constants or the special MAXVALUE keyword.

The server halts the DDL statement to prevent undefined placement of rows containing NULL, because NULL is never equal or less than any numeric value in MySQL.

When does this error occur?

The error commonly arises during CREATE TABLE, ALTER TABLE, or EXCHANGE PARTITION commands that include a VALUES LESS THAN clause with NULL.

It also appears when executing mysqldump scripts generated from another system that unintentionally wrote NULL into partition boundaries.

Why is fixing it important?

Leaving the definition invalid blocks table creation or modification, stopping deployments and delaying schema migrations.

Fixing the error ensures partitions compile, improves query performance, and keeps data correctly routed across partitions.

Common Causes

Using NULL in partition range

Developers mistakenly insert NULL directly inside VALUES LESS THAN (NULL).

Relying on application defaults

Application code inserts NULL into boundary values when dynamic DDL builds partition lists.

Incorrect migration scripts

Migrations cloned from other databases may include NULL boundaries that are valid elsewhere but not in MySQL.

Misunderstanding MAXVALUE

Teams think NULL works like MAXVALUE, causing them to substitute NULL for an open-ended range.

Related Errors

MySQL Error 1491 ER_PARTITION_FUNCTION_IS_NOT_ALLOWED

Triggered when you use non-deterministic functions in partition expressions.

MySQL Error 1493 ER_PARTITION_MAXVALUE

Occurs if MAXVALUE appears in a non-last partition.

MySQL Error 1736 ER_DROP_PARTITION_NON_EXISTENT

Raised when attempting to drop a partition that does not exist.

FAQs

Can I ever store NULL rows in a range partitioned table?

Yes. Ensure the partition key column is NOT NULL or add a default value. NULL rows can then be inserted; the storage engine routes them to the appropriate partition based on other rules.

Does LIST partitioning allow NULL in VALUES IN?

No. Similar to RANGE, LIST partitioning forbids NULL in VALUES IN lists. Use MAXVALUE or a placeholder value instead.

Will setting sql_mode affect this error?

No. Error 1566 is enforced at the partition parser level and is independent of sql_mode settings.

How does Galaxy help prevent this error?

Galaxy highlights invalid partition syntax in real time, suggests MAXVALUE replacements through its AI copilot, and lets teams review DDL collaboratively to catch NULL boundaries before deployment.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo