View previous topic :: View next topic
|
Author |
Message |
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
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 |
|
|
ashwinreddy
Active User
Joined: 16 Sep 2004 Posts: 106 Location: Hyderabad
|
|
Back to top |
|
|
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
I tried with this syntax...
in db2 i think we need to use drop constraint key word. |
|
Back to top |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
Hi.......
You can do it by using ALTER Command............ |
|
Back to top |
|
|
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
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 |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
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 |
|
|
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
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 |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
Hi..
Just try the below statement and let me know.
Code: |
ALTER TABLE TABLE-NAME MODIFY COLUMN-NAME TYPE(SIZE); |
|
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
I think you will have to drop the table and redefine it. |
|
Back to top |
|
|
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
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 |
|
|
|