Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-30 · container image gvenzl/oracle-free:23-slim
ORA-02296 is raised by ALTER TABLE ... MODIFY (column NOT NULL). Oracle checks every existing row, and if even one has NULL in that column the change stops. In the message the constraint name is empty, as in (LAB_A.), because the NOT NULL constraint was never created.
In the lab the NULLs came from a customer saved without an email, and from a backfill UPDATE that found no match for one row. In both cases WHERE column IS NULL showed the rows, and the column became NOT NULL after they were filled.
01Some existing rows have NULL in the column
customers had 3 rows and customer 2 had no email. ALTER TABLE customers MODIFY (email NOT NULL); failed with cannot enable (LAB_A.) - null values found.
After setting that email to 'unknown@example.com', the same ALTER TABLE succeeded and USER_TAB_COLUMNS showed NULLABLE = N for EMAIL.
Setup
CREATE TABLE customers (cust_id NUMBER PRIMARY KEY, name VARCHAR2(30), email VARCHAR2(50));
INSERT INTO customers VALUES (1, 'Kim', 'kim@example.com');
INSERT INTO customers VALUES (2, 'Lee', NULL);
INSERT INTO customers VALUES (3, 'Park', 'park@example.com');
COMMIT;Table created.
1 row created.
1 row created.
1 row created.
Commit complete.ALTER TABLE customers MODIFY (email NOT NULL);ALTER TABLE customers MODIFY (email NOT NULL)
*
ERROR at line 1:
ORA-02296: cannot enable (LAB_A.) - null values found
Help: https://docs.oracle.com/error-help/db/ora-02296/SELECT cust_id, name FROM customers WHERE email IS NULL; CUST_ID NAME
---------- ------------------------------
2 Lee
1 row selected.WHERE email IS NULL returned only customer 2 (Lee), the row blocking the change.
UPDATE customers SET email = 'unknown@example.com' WHERE email IS NULL;
COMMIT;1 row updated.
Commit complete.Fill the NULL rows with a real or placeholder value first (or delete them, if they are junk), then run MODIFY again.
ALTER TABLE customers MODIFY (email NOT NULL);
COLUMN column_name FORMAT A12
SELECT column_name, nullable FROM user_tab_columns WHERE table_name = 'CUSTOMERS' ORDER BY column_id;Table altered.
COLUMN_NAME N
------------ -
CUST_ID N
NAME Y
EMAIL N
3 rows selected.02A new column was backfilled with UPDATE, but some rows had no match
A manager column was added to stores and filled with UPDATE ... SET manager = (SELECT ... FROM regions ...). Store 3 has region ICN, which is not in regions, so the subquery returned nothing and the value stayed NULL. MODIFY (manager NOT NULL) then failed with ORA-02296.
After setting the remaining NULL to 'TBD', the change succeeded: stores 1 and 2 kept Choi and Jung, store 3 got TBD.
Setup
CREATE TABLE regions (region_code VARCHAR2(5) PRIMARY KEY, manager VARCHAR2(20));
INSERT INTO regions VALUES ('SEL', 'Choi');
INSERT INTO regions VALUES ('BSN', 'Jung');
CREATE TABLE stores (store_id NUMBER PRIMARY KEY, region_code VARCHAR2(5));
INSERT INTO stores VALUES (1, 'SEL');
INSERT INTO stores VALUES (2, 'BSN');
INSERT INTO stores VALUES (3, 'ICN');
COMMIT;
ALTER TABLE stores ADD (manager VARCHAR2(20));
UPDATE stores s SET manager = (SELECT r.manager FROM regions r WHERE r.region_code = s.region_code);
COMMIT;Table created.
1 row created.
1 row created.
Table created.
1 row created.
1 row created.
1 row created.
Commit complete.
Table altered.
3 rows updated.
Commit complete.ALTER TABLE stores MODIFY (manager NOT NULL);ALTER TABLE stores MODIFY (manager NOT NULL)
*
ERROR at line 1:
ORA-02296: cannot enable (LAB_A.) - null values found
Help: https://docs.oracle.com/error-help/db/ora-02296/SELECT s.store_id, s.region_code, s.manager FROM stores s WHERE s.manager IS NULL; STORE_ID REGIO MANAGER
---------- ----- --------------------
3 ICN
1 row selected.The query returned store 3 with region ICN and an empty manager: the backfill found no region row for it.
UPDATE stores SET manager = 'TBD' WHERE manager IS NULL;
COMMIT;1 row updated.
Commit complete.After a backfill, check IS NULL before adding NOT NULL. Rows without a match in the source table need a separate value.
ALTER TABLE stores MODIFY (manager NOT NULL);
SELECT store_id, region_code, manager FROM stores ORDER BY store_id;Table altered.
STORE_ID REGIO MANAGER
---------- ----- --------------------
1 SEL Choi
2 BSN Jung
3 ICN TBD
3 rows selected.FAQ
Why is the constraint name empty in ORA-02296 (LAB_A.)?
MODIFY (column NOT NULL) without a name tries to create a new constraint, and it failed before it got a name. The lab message was cannot enable (LAB_A.) - null values found.
How do I find the rows that block NOT NULL?
Query the column with IS NULL, e.g. SELECT cust_id, name FROM customers WHERE email IS NULL;. In the lab it returned the single row that caused the error.
ORA-02296 after adding a column and running UPDATE — why?
The UPDATE left NULL in rows it could not fill. In the lab a store whose region did not exist in the lookup table stayed NULL. Fill those rows separately, then add NOT NULL.
How do I check the column is NOT NULL now?
Look at USER_TAB_COLUMNS: after the fix the lab showed EMAIL with NULLABLE = N.
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