ORA-01449: column contains NULL values; cannot alter to NOT NULL

kIsH@STAX<>!oerr ora 1449
01449, 00000, “column contains NULL values; cannot alter to NOT NULL”
// *Cause: An ALTER TABLE MODIFY statement attempted to change the
// definition of a column containing NULL values to NOT NULL. The
// column may not currently contain any NULL values if it was to
// be altered to NOT NULL.
// *Action: Set all NULL values in the column to values other than
// NULL before ALTERING the column to NOT NULL.

kIsH@STAX<>create table dbobj as select * from dba_objects;

Table created.

kIsH@STAX<>alter table dbobj add constraint objcon primary key (object_id);
alter table dbobj add constraint objcon primary key (object_id)
                                                     *
ERROR at line 1:
ORA-01449: column contains NULL values; cannot alter to NOT NULL


kIsH@STAX<>delete from dbobj where object_id IS NULL;

4 rows deleted.

kIsH@STAX<>commit;

Commit complete.

kIsH@STAX<>alter table dbobj add constraint objcon primary key (object_id);

Table altered.

Leave a Reply