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.

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s