Could you please suggest me, How to add not null constraint to an existing column which has null values?
SQL> create table nn ( n number, s varchar2(10));
Table created.
SQL> insert into nn values (1,'test');
1 row created.
SQL> insert into nn values (2,'');
1 row created.
SQL> commit;
Commit complete.
SQL> alter table nn modify n number not null;
Table altered.
SQL> desc nn;
Name Null? Type
----------------------------------------- -------- ----------------------------
N NOT NULL NUMBER
S VARCHAR2(10)
SQL> alter table nn modify n number null;
Table altered.
SQL> desc nn;
Name Null? Type
----------------------------------------- -------- ----------------------------
N NUMBER
S VARCHAR2(10)
SQL> alter table nn modify s varchar2(10) not null;
alter table nn modify s varchar2(10) not null
*
ERROR at line 1:
ORA-02296: cannot enable (SCOTT.) - null values found
SQL>