IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Constraint Modification for a column.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Alien3

New User


Joined: 03 Nov 2005
Posts: 2

PostPosted: Mon Nov 07, 2005 7:08 pm
Reply with quote

Hi,

A column in a table has been defined as Not Null.
I need to make it Not Null with default.
Could somebody please advice how to do it without recreating the table.

Thanks
Back to top
View user's profile Send private message
ravisan
Warnings : 1

New User


Joined: 13 Sep 2005
Posts: 13
Location: chennai

PostPosted: Mon Nov 07, 2005 7:20 pm
Reply with quote

I think , we can try using ALTER.......?
Back to top
View user's profile Send private message
tam

New User


Joined: 02 Nov 2005
Posts: 12
Location: zz

PostPosted: Wed Nov 09, 2005 11:47 am
Reply with quote

I think first you've to drop that column and then add it as not null with default.

ALTER TABLE <table_name>
ADD COLUMN <column_name> <column_type>
NOT NULL WITH DEFAULT
Back to top
View user's profile Send private message
Alien3

New User


Joined: 03 Nov 2005
Posts: 2

PostPosted: Thu Nov 10, 2005 9:00 pm
Reply with quote

Hi Tam,

Thanks for the suggestion but the table contains data.
If i drop the column won't i lose the data?
Back to top
View user's profile Send private message
tam

New User


Joined: 02 Nov 2005
Posts: 12
Location: zz

PostPosted: Mon Nov 14, 2005 2:28 pm
Reply with quote

Hi Alien3,
Yeah you'll lose data but I'm not sure if you can update the column type without dropping the column.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts first column truncated in search result IBM Tools 13
No new posts Split a record with data in a differe... DFSORT/ICETOOL 8
Search our Forums:

Back to Top