DB2 V9 on Windows :
I have a table that is already populated with Data that the Developer wants me to add a coumn to. The colulm is this:
Code:
ALTER TABLE KCDWHPRC.TPH_TEST ADD "MXDX_7PAY_TYP_CD" CHAR(1) NOT NULL
When I try and add the column I get this error:
Code:
ALTER TABLE KCDWHPRC.TPH_TEST ADD "MXDX_7PAY_TYP_CD" CHAR(1) NOT NULL
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0193N In an ALTER TABLE statement, the column "MXDX_7PAY_TYP_CD" has been
specified as NOT NULL and either the DEFAULT clause was not specified or was
specified as DEFAULT NULL. SQLSTATE=42601
SQL0193N In an ALTER TABLE statement, the column "MXDX_7PAY_TYP_CD " has been specified as NOT NULL and either the DEFAULT clause was not specified or was specified as DEFAULT NULL.
Explanation:
When new columns are added to a table that already exists, a
value must be assigned to that new column for all existing rows.
By default, the null value is assigned. However, since the
column has been defined as NOT NULL, a default value other than
null must be defined.
It works when I add the column like this:
Code:
ALTER TABLE KCDWHPRC.TPH_TEST ADD "MXDX_7PAY_TYP_CD" CHAR(1) NOT NULL WITH DEFAULT
But they don't want to use 'WITH DEFAULT' in the DDL. Is there any way to add a NOT NULL COLUMN to a table that is already loaded with Data?