Page 1 of 1

How to drop 2 columns from DB2 table?

PostPosted: Thu Oct 30, 2014 12:31 pm
by shankar_dh
Hi,

I believe we do not have DROP COLUMN facility in DB2.
I have 8 columns in my table.I need to drop 2 columns.
Do we need to create new table with only 6 columns and drop the old table? If so, how to take care of the data what we already have in the table?
Can anybody suggest me best approach to do so?

Re: How to drop 2 columns from DB2 table?

PostPosted: Thu Oct 30, 2014 6:44 pm
by NicC
It may depend on your level of DB2. I found this article when Googling:
http://ibmsystemsmag.com/Blogs/db2utor/Archive/drop-column-support/

Re: How to drop 2 columns from DB2 table?

PostPosted: Thu Oct 30, 2014 7:22 pm
by shankar_dh
Hi Nic,

Thanks for the reply.
But, I have 10.1 version.

Thanks,
Shankar.

Re: How to drop 2 columns from DB2 table?

PostPosted: Mon Nov 17, 2014 7:52 pm
by shankar_dh
Hi Forum,

Any more suggestions for my post??

Re: How to drop 2 columns from DB2 table?

PostPosted: Tue Nov 18, 2014 4:32 am
by NicC
You need to do as your original post suggested. Create a new table without the 2 columns that are to be dropped. Populate the new table from the old table. Drop the old table. That appears to be the only way to do it.

Re: How to drop 2 columns from DB2 table?

PostPosted: Thu Nov 20, 2014 7:10 pm
by heshmahesh
Hi,
please check this if it works

ALTER TABLE <table.name> DROP COLUMN <column.name>.

Re: How to drop 2 columns from DB2 table?

PostPosted: Thu Nov 20, 2014 7:20 pm
by enrico-sorichetti
please check this if it works


did You look at the constraints listed in the link posted by Nic ?

Re: How to drop 2 columns from DB2 table?

PostPosted: Thu Nov 20, 2014 7:29 pm
by heshmahesh
Ya.. i,m sorry.,we can do by the way as Nic said..