If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > delete a column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-28-07, 01:36
ravi30 ravi30 is offline
Registered User
 
Join Date: Dec 2007
Posts: 7
delete a column

is it possible to delete a column of a table! if so how can i?

thanx
Reply With Quote
  #2 (permalink)  
Old 12-28-07, 01:59
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
At least in DB2 for z/os there is no SQL-statement to drop a column from a table. You have to DROP and reCREATE it
Reply With Quote
  #3 (permalink)  
Old 12-28-07, 01:59
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Code:
ALTER TABLE ... DROP COLUMN ...
Whether this works depends on your DB2 version and underlying platform.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 12-28-07, 04:11
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
It works on DB2 V9 for UNIX, Linux, Windows. If you don't have version 9, you have to drop the table and recreate it without the column. If that is not possible, the just ignore the column since DB2 (or Oracle) doesn't actually physically remove it from each row when you drop a column (at least until you do a reorg).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 12-28-07, 05:25
ravi30 ravi30 is offline
Registered User
 
Join Date: Dec 2007
Posts: 7
im using z/os so can't i even do it with the alter command?
i suppose i can create a new column with the alter though? isn't it?
Reply With Quote
  #6 (permalink)  
Old 12-28-07, 06:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
ALTER TABLE (it's a SQL statement - not a command) on DB2 z/OS does not allow you to drop a column. Adding a column is supported, however.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 12-28-07, 08:34
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by ravi30
is it possible to delete a column of a table! if so how can i?
Superfluous columns in a table are normally not a problem for DML access.
If it's important to "hide" a particular column, you may RENAME the original table and CREATE a VIEW with the old table name, referring the new table name, where that view has one column less than the table.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #8 (permalink)  
Old 12-28-07, 09:06
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
is there SYSPROC.ALTOBJ system store procedure on DB2/zOS? This store procedure exist from v8 on LUW and can be helpful.
Hope this helps,
Grofaty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On