Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ 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
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    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

ravisan
Warnings : 1

New User


Joined: 13 Sep 2005
Posts: 13
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us