ORA-02296: cannot enable (string.) – null values found

Hi all!
Found the error below?

greporadb> alter table TABLE_TEST modify COLUMN_TEST not null;
alter table TABLE_TEST modify COLUMN_TEST not null
*
ERROR at line 1:
ORA-02296: cannot enable (MATHEUSDBA.) - null values found

It happen basically because you have null values for this column. Let’s check:

greporadb> SELECT COUNT(*)  FROM TABLE_TEST WHERE COLUMN_TEST IS NULL;
COUNT(*)
----------
99

Ok doke!
Now, what can we do?
1) Fix the problem updating the null values to a value (or a dummy value).
2) Use NOVALIDATE clause, like:

greporadb> alter table TABLE_TEST modify COLUMN_TEST not null NOVALIDATE;
Table altered.

Is a good practice to set a default value for this column too.
It’s a probability that some kind of behavior (even a bug) on application is causing the null values, so, setting a default value, you avoid “new errors” on application layer.
Otherside, if you want to show where the bug is occouring, maybe is better to not set it…

Hope it helped you.
Have a nice day!
Matheus.

One thought on “ORA-02296: cannot enable (string.) – null values found

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.