Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-19 · container image gvenzl/oracle-free:23-slim
ORA-01407 is the UPDATE version of ORA-01400. The message names the column as ("LAB_A"."EMPLOYEES"."DEPT_CODE"): schema, table, column. That column is NOT NULL and the new value was NULL.
Often nobody wrote NULL on purpose. A subquery that returns no row, or an empty string '', also becomes NULL. The whole statement fails, so no row is changed.
02Setting the column to an empty string ''
UPDATE employees SET emp_name = '' looks like it stores an empty string, but in Oracle '' is NULL in VARCHAR2. The check CASE WHEN '' IS NULL ... returns NULL.
So a NOT NULL text column cannot be "blank". Here a placeholder value '-' was stored instead and the UPDATE succeeded.
Setup
CREATE TABLE employees (emp_id NUMBER PRIMARY KEY, emp_name VARCHAR2(30) NOT NULL, dept_code VARCHAR2(10) NOT NULL);
CREATE TABLE dept_map (old_code VARCHAR2(10), new_code VARCHAR2(10));
INSERT INTO employees VALUES (1, 'Kim', 'D10');
INSERT INTO employees VALUES (2, 'Lee', 'D20');
INSERT INTO employees VALUES (3, 'Park', 'D99');
INSERT INTO dept_map VALUES ('D10', 'S10');
INSERT INTO dept_map VALUES ('D20', 'S20');
COMMIT;Table created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Commit complete.UPDATE employees SET emp_name = '' WHERE emp_id = 3;UPDATE employees SET emp_name = '' WHERE emp_id = 3
*
ERROR at line 1:
ORA-01407: cannot update ("LAB_A"."EMPLOYEES"."EMP_NAME") to NULL
Help: https://docs.oracle.com/error-help/db/ora-01407/SELECT CASE WHEN '' IS NULL THEN 'NULL' ELSE 'NOT NULL' END AS empty_string FROM dual;EMPTY_ST
--------
NULL
1 row selected.Code moved from MySQL or SQL Server often relies on '' being different from NULL. Decide on a real placeholder value, or allow NULL.
UPDATE employees SET emp_name = '-' WHERE emp_id = 3;
SELECT emp_id, emp_name FROM employees ORDER BY emp_id;1 row updated.
EMP_ID EMP_NAME
---------- ------------------------------
1 Kim
2 Lee
3 -
3 rows selected.03SET col = NULL on a column defined as NOT NULL
UPDATE employees SET dept_code = NULL fails because USER_TAB_COLUMNS shows NULLABLE = N for DEPT_CODE.
If the business rule really allows an empty department, change the column with ALTER TABLE employees MODIFY (dept_code NULL). After that the same UPDATE ran and employee 3's DEPT_CODE is empty.
Setup
CREATE TABLE employees (emp_id NUMBER PRIMARY KEY, emp_name VARCHAR2(30) NOT NULL, dept_code VARCHAR2(10) NOT NULL);
CREATE TABLE dept_map (old_code VARCHAR2(10), new_code VARCHAR2(10));
INSERT INTO employees VALUES (1, 'Kim', 'D10');
INSERT INTO employees VALUES (2, 'Lee', 'D20');
INSERT INTO employees VALUES (3, 'Park', 'D99');
INSERT INTO dept_map VALUES ('D10', 'S10');
INSERT INTO dept_map VALUES ('D20', 'S20');
COMMIT;Table created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Commit complete.UPDATE employees SET dept_code = NULL WHERE emp_id = 3;UPDATE employees SET dept_code = NULL WHERE emp_id = 3
*
ERROR at line 1:
ORA-01407: cannot update ("LAB_A"."EMPLOYEES"."DEPT_CODE") to NULL
Help: https://docs.oracle.com/error-help/db/ora-01407/SELECT column_name, nullable FROM user_tab_columns WHERE table_name = 'EMPLOYEES' ORDER BY column_id;COLUMN_NAME N
------------------------------ -
EMP_ID N
EMP_NAME N
DEPT_CODE N
3 rows selected.Remove NOT NULL only when the rule has really changed. If not, the UPDATE needs a real value.
ALTER TABLE employees MODIFY (dept_code NULL);
UPDATE employees SET dept_code = NULL WHERE emp_id = 3;
SELECT emp_id, dept_code FROM employees ORDER BY emp_id;Table altered.
1 row updated.
EMP_ID DEPT_CODE
---------- ----------
1 D10
2 D20
3
3 rows selected.FAQ
How do I find which column causes ORA-01407?
The message shows it as ("SCHEMA"."TABLE"."COLUMN"). The last part is the column.
My UPDATE with a subquery fails with ORA-01407 but the subquery has no NULLs. Why?
Some rows have no matching row in the subquery, so the subquery returns nothing and the value becomes NULL. Add WHERE EXISTS with the same condition so only matching rows are updated.
Why does setting a column to '' give ORA-01407?
In Oracle, an empty string '' is treated as NULL. A NOT NULL VARCHAR2 column cannot hold it.
What is the difference between ORA-01407 and ORA-01400?
ORA-01400 comes from INSERT, ORA-01407 from UPDATE. Both mean a NOT NULL column would get NULL.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0