Link to home
Start Free TrialLog in
Avatar of Nakuru1234
Nakuru1234

asked on

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

Hello,

I am executing this query but I keep getting an error message

ALTER TABLE UTG.PARAMETER
 ADD CONSTRAINT PARAMETER_PK
 PRIMARY KEY
 (PARAM_ID, CIR_TYPE)

Error at line 1
ORA-01449: column contains NULL values; cannot alter to NOT NULL

How can I be able to add a PK on both columns (PARAM_ID, CIR_TYPE) and make them NOT NULL without this error message?

TIA,
N.
SOLUTION
Avatar of Muhammad Ahmad Imran
Muhammad Ahmad Imran
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of David VanZandt
David VanZandt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nakuru1234
Nakuru1234

ASKER

Please provide the sql syntax to add the values or to update the rows in the PARAMETER table, replacing NULL with a not null value. Thanks.

N.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DESCribe the table please so we can try creating an update statement, if possible show some records, redacting contents if needed.
//DESCribe the table please so we can try creating an update statement
Table name is PARAMETER
Column names; PARAM_ID (VARCHAR2) (32) and CIR_TYPE (VARCHAR2) (16)

//if possible show some records, redacting contents if needed.
PARAM_ID      CIR_TYPE
frameFmt      ds1
lineCode                      ds1
tid                      ds1
aid                      ds1
ortn                      ds1
direction                      ds1
hexBinPattern      ds1
pattern                      ds1

I just tried this again...

SQL> ALTER TABLE UTG.PARAMETER
 ADD PRIMARY KEY
 (PARAM_ID, CIR_TYPE)
ALTER TABLE UTG.PARAMETER
 ADD PRIMARY KEY
 (PARAM_ID, CIR_TYPE)
Error at line 3
ORA-01449: column contains NULL values; cannot alter to NOT NULL

N.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
select count * from utg.parameter where param_id is NULL;

  COUNT(*)
----------
         0
1 row selected.


select count * from utg.parameter where cir_type is NULL;

  COUNT(*)
----------
         6
1 row selected.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, that worked :) Thank you.

N.
@dvz - Uhm, yes... I was asking for some details and yes I filled in the blanks....