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

changing column type from 'not null' to null


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
Reply with quote

Hi,

Found some notes in Google, hope this helps


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
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: 275
Location: Bang,iflex

PostPosted: Tue Mar 11, 2008 3:03 pm
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
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: 275
Location: Bang,iflex

PostPosted: Tue Mar 11, 2008 3:27 pm
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
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: 275
Location: Bang,iflex

PostPosted: Tue Mar 11, 2008 4:23 pm
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
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
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 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 changing defaults in db2 admin - Unlo... DB2 0
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top