If you’re getting error 1138 that reads “invalid use of NULL value“, it could be because you’re trying to change the definition of a column to require non-NULL
values, but the column contains NULL
values.
This can happen when we try to change a column from NOT NULL
to NULL
. It can also happen when we try to set a column as a primary key, but that column contains NULL
values.
To fix this issue, be sure to ensure that the column you’re modifying doesn’t contain any NULL
values. Alternatively, if the column should be able to accept NULL
values, then you should change your column definition to allow NULL
values.