Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Constraint Modification for a column.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
Alien3

New User


Joined: 03 Nov 2005
Posts: 2

PostPosted: Mon Nov 07, 2005 7:08 pm    Post subject: Constraint Modification for a column.
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
References
ravisan
Warnings : 1

New User


Joined: 13 Sep 2005
Posts: 14
Location: chennai

PostPosted: Mon Nov 07, 2005 7:20 pm    Post subject:
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    Post subject:
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    Post subject: Re: Constraint Modification for a column.
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    Post subject:
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1