DBAtlas · Database operations atlas

ORA-01400: cannot insert NULL into (column)

Oracle

What does it mean?

A NULL value was inserted into, or set on, a column with a NOT NULL constraint. A mandatory field cannot be left empty.

Why does it happen?

No value supplied for a mandatory column in an INSERT, an UPDATE setting the column to NULL, no DEFAULT defined for the column, or an empty value coming from a subquery/application.

How to fix it

Supply a valid value for the column named in the error message. Define a sensible default for the column: ALTER TABLE my_table MODIFY (my_column DEFAULT 0); (DEFAULT applies only when the column is omitted from the INSERT entirely; for explicitly sent NULL values use 12c+ DEFAULT ON NULL: ALTER TABLE my_table MODIFY (my_column DEFAULT ON NULL 0);) If the rule is not truly mandatory, drop the constraint: ALTER TABLE my_table MODIFY (my_column NULL); Validate empty values in the application before sending them.

Open in DBAtlas →

More from this engine