what is sql code to delete column ?

IBM's flagship relational database management system

what is sql code to delete column ?

Postby ballaravi » Sat Jul 31, 2010 6:46 pm

what is sql code to delete column in db2?
ballaravi
 
Posts: 18
Joined: Wed Jul 14, 2010 6:19 pm

References:

Re: what is sql code to delete column ?

Postby NicC » Sat Jul 31, 2010 10:08 pm

I am not sure if you can delete a column unless it has come in in recent versions of DB2. The normal way is to drop the table and recreate it with the new definition.
Regards
Nic
NicC
 
Posts: 147
Joined: Sun Jul 04, 2010 12:13 am

Re: what is sql code to delete column ?

Postby dick scherrer » Sun Aug 01, 2010 5:17 am

Hello,

There are often problems with terminology - what does "delete a column" mean to you?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 3393
Joined: Sat Jun 09, 2007 8:58 am

Re: what is sql code to delete column ?

Postby ballaravi » Mon Aug 09, 2010 8:07 pm

just consider in an EMP table i have columns (empno,empname,salary,deptno).
now i dont what to deptno on the EMP table, how to delete that column.
ballaravi
 
Posts: 18
Joined: Wed Jul 14, 2010 6:19 pm

Re: what is sql code to delete column ?

Postby NicC » Mon Aug 09, 2010 8:30 pm

1) unload the data from the current table but ignore the data in the column that you do not want
2) drop the table
3) recreat the table with the new definition
4) load the table from the saved data
Regards
Nic
NicC
 
Posts: 147
Joined: Sun Jul 04, 2010 12:13 am

Re: what is sql code to delete column ?

Postby ballaravi » Tue Aug 10, 2010 4:23 pm

ok,good idea only, but in sql server and oracle we can delete the column direcly, need of above septs, why it is not in db2. thats why i asked.if we have more data it is difficcult one..

ok thank you... for ur answer.. :)
ballaravi
 
Posts: 18
Joined: Wed Jul 14, 2010 6:19 pm


Return to DB2

Who is online

Users browsing this forum: Google Adsense [Bot] and 2 guests