I'm using db2 version 9.7* and it seems impossible to make a NOT NULL column nullable in any straightforward way.
Unfortunately the solution of using a more developer friendly database is not available. Basically, in MySQL speak, I want to do something like this (where MY_COLUMN used to be VARCHAR(200) NOT NULL) :
ALTER TABLE MY_TABLE MODIFY COLUMN MY_COLUMN VARCHAR(200);
If you have a column that does not allow the null value and you want to change it to now allow the null value, use the DROP NOT NULL clause. If you have a column that allows the null value and you want to prevent the use of null values, use the SET NOT NULL clause.
ALTER TABLE table_name ALTER COLUMN column_name DATA_TYPE [(COLUMN_SIZE)] NULL; In this syntax: First, specify the name of the table from which you want to change the column. Second, specify the column name with size which you want to change to allow NULL and then write NULL statement .
It means, if a column nullable type is defined as 0, it means it cannot be NULL, every time it will have some value.
My final query ended up something like this:
ALTER TABLE MY_TABLE DATA CAPTURE NONE;
ALTER TABLE MY_TABLE ALTER MY_COLUMN DROP NOT NULL;
ALTER TABLE MY_TABLE DATA CAPTURE CHANGES;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With