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
Has thanked: 0 time
Been thanked: 0 time

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

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
Has thanked: 0 time
Been thanked: 0 time

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
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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
Has thanked: 0 time
Been thanked: 0 time

Re: what is sql code to delete column ?

Postby R.V.N.REDDY » Mon Sep 20, 2010 10:37 pm

ALTER TABLE table_name DELETE COLUMN column-name


This is the command used to delete the existing column from the table
R.V.N.REDDY
 
Posts: 1
Joined: Mon Sep 20, 2010 10:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: what is sql code to delete column ?

Postby NicC » Mon Sep 20, 2010 11:48 pm

ALTER TABLE table_name DELETE COLUMN column-name


Which version of DB2 is this from? I have checked the ALTER TABLE syntax in version 8 and column deletion is NOT supported.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: what is sql code to delete column ?

Postby dick scherrer » Tue Sep 21, 2010 12:17 am

Hello,

IIRC, this is is from DB2 LUW, not mainframe. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post