Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
changing column type from 'not null' to null

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue Mar 11, 2008 11:47 am    Post subject: changing column type from 'not null' to null
Reply with quote

Hi all,

Is there any way to change the column type from 'not null' to null.

I have created a table with column type as not null, now i would like to change it to null.

Please let me know if there any way to do it.

Many thanks,
Jai
Back to top
View user's profile Send private message

ashwinreddy

Active User


Joined: 16 Sep 2004
Posts: 106
Location: Hyderabad

PostPosted: Tue Mar 11, 2008 12:06 pm    Post subject:
Reply with quote

Hi,

Found some notes in Google, hope this helps


http://www.mckoi.com/database/mail/subject.jsp?id=7300


Cheers
Ashwin
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue Mar 11, 2008 2:18 pm    Post subject:
Reply with quote

I tried with this syntax...

in db2 i think we need to use drop constraint key word.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
Location: Bang,iflex

PostPosted: Tue Mar 11, 2008 3:03 pm    Post subject:
Reply with quote

Hi.......

You can do it by using ALTER Command............
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue Mar 11, 2008 3:18 pm    Post subject:
Reply with quote

I tried using the following query but it is giving error

Alter table <table name>
drop constraint <column name>;

Can u please correct it if nay thing is missing.

Thanks
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
Location: Bang,iflex

PostPosted: Tue Mar 11, 2008 3:27 pm    Post subject:
Reply with quote

Hi.......

If u drop constraint the related foreign key relation ships will also be get affected. you just want to change "NOT NULL' to 'NULL". You can just go for ALTER COLUMN statement
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue Mar 11, 2008 3:45 pm    Post subject:
Reply with quote

Thanks for your help Dear,

Still iam facing the problem with syntax... if you don't mind can you please provide me the complete syntax?

Regards,
Jai
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
Location: Bang,iflex

PostPosted: Tue Mar 11, 2008 4:23 pm    Post subject:
Reply with quote

Hi..

Just try the below statement and let me know.


Code:
ALTER TABLE TABLE-NAME MODIFY COLUMN-NAME TYPE(SIZE);
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 11, 2008 5:00 pm    Post subject:
Reply with quote

I think you will have to drop the table and redefine it.
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue Mar 11, 2008 5:32 pm    Post subject:
Reply with quote

I think there is a way... but iam unable to do it....

The query given by Vasanth is also giving error....

Any other ideas...

Regards,
Jai
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 column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Setting Font Type for XMIT satish.ms10 All Other Mainframe Topics 3 Fri Sep 15, 2017 10:01 pm
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Changing sort Card Dynamically vickey_dw DFSORT/ICETOOL 5 Sat Aug 19, 2017 2:33 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us