MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Change columns from NULL to NOT NULL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Mon Jan 20, 2020 1:57 pm    Post subject: Change columns from NULL to NOT NULL Reply with quote

Hi,

We added a new column to the existing table and defined it as NULLABLE.

We would like to change it to NOT NULL.

Could you help the best way to do this?

We are using DB2 version 12

Vijay
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12354
Topics: 75
Location: San Jose

PostPosted: Tue Jan 21, 2020 12:25 am    Post subject: Reply with quote

vijay,

With ALTER command you can only change the default but not the nullability attribute. You have to DROP and recreate the table.

So you need to

1. Unload the table
2. Drop the table
3. Create the table with column set to NOT null with a default value
4. Modify the unload file from step1 to have a default value for the column whose prior value is null
5. Reload the table
6. REORG the table (not necessary but advisable)
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group