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 > Alter Table Drop Column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-25-06, 09:51
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Alter Table Drop Column

Is this possible in DB2 OS/390 V 7.2?

Apparently the answer seems to be no.

UNLOAD/DROP/CREATE/LOAD/GRANT/REBIND

What a total pain in the donkey

Any other alternative?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #2 (permalink)  
Old 05-25-06, 11:32
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
That is why most shops have tools like BMC ALTER which will do all of that for you automatically. There is little incentive for IBM to make these changes online because of the widespread use of these tools.
__________________
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
  #3 (permalink)  
Old 05-25-06, 11:48
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Quote:
Originally Posted by Marcus_A
That is why most shops have tools like BMC ALTER which will do all of that for you automatically. There is little incentive for IBM to make these changes online because of the widespread use of these tools.

I say this with all the love I can muster because I got into this business because of DB2 Big Iron....

I hate IBM
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #4 (permalink)  
Old 05-25-06, 11:49
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Not that I'm a big fan of the evil empire either....


What does BMC stand for btw
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #5 (permalink)  
Old 05-28-06, 14:40
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
It depends on what you really want to achieve.

* If it's sufficient to make that column invisible to users, you may create a view.
* If it's really for saving space, and the column is a VARCHAR, make all entries empty (and optionally create the view).
* If it's not a VARCHAR, and you're on v8, first
ALTER TABLE tab-name ALTER col-name SET DATA TYPE VARCHAR(n)
with n sufficiently large, then change the values.

Dropping and re-creating the table, the only "real" solution, has the big disadvantage that everything referring that table (like views, referential constraints, packages, indexes, ...) are either dropped or invalidated. That's what BMC (http://www.bmc.com/) tries to compensate for, but in most cases you're better off keeping the column...
__________________
--_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
  #6 (permalink)  
Old 05-31-06, 03:45
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
read this out!!! There is an excellent solution to solve the problem:
http://dbforums.com/showthread.php?t=1217586
http://dbforums.com/showthread.php?t=1217517

To drop column in db2 v8.2 for LUW (don't know is this works for DB2 for zOS):
Code:
CREATE TABLE SCHEM1.TB_TEST1 (COL1 SMALLINT NOT NULL, COL2 DEC(7,4));
INSERT INTO SCHEM1.TB_TEST1 VALUES (1,1);
SELECT * FROM SCHEM1.TB_TEST1;

DESCRIBE TABLE SCHEM1.TB_TEST1;

CALL SYSPROC.ALTOBJ ('APPLY_CONTINUE_ON_ERROR', 'CREATE TABLE SCHEM1.TB_TEST1 (COL1 SMALLINT NOT NULL)', -1, ? );

DESCRIBE TABLE SCHEM1.TB_TEST1;

SELECT * FROM SCHEM1.TB_TEST1;
The beauty: column is deleted and no export is needed!

Note: be very very very carful what are you doing with this sysproc.altobj store procedure, because there is no way back.

Hope this helps,
Grofaty

Last edited by grofaty; 05-31-06 at 03:48.
Reply With Quote
  #7 (permalink)  
Old 05-31-06, 03:58
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by Brett Kaiser
What does BMC stand for btw
Something like Bonner, Moore, and Cluer (3 guys who started the company). I met one of these guys (forgot which one) in Houston about 1981 when they were a small IT consulting company who also had started developing some IMS utility tools.
__________________
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
  #8 (permalink)  
Old 05-31-06, 04:03
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by Brett Kaiser
I say this with all the love I can muster because I got into this business because of DB2 Big Iron....

I hate IBM
Most people use 3rd party front-end administration tools for DB2 and Oracle databases. MS SQL Server probably has the best front-end, but even for that some DBA's use 3rd party tools.

BTW, Microsoft is now the Evil Empire. Where have you been for the last 10 years?
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390

Last edited by Marcus_A; 06-01-06 at 02:58.
Reply With Quote
  #9 (permalink)  
Old 05-31-06, 04:06
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by grofaty
To drop column in db2 v8.2 for LUW (don't know is this works for DB2 for zOS)
No it does not work for z/OS.

BTW, on LUW the SP does export the data, drop the table, recreate the table, and reload the data. It just does it without you seeing it.
__________________
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
  #10 (permalink)  
Old 05-31-06, 04:15
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
The "SYSPROC.ALTOBJ() " sp for dropping a Column works only in UDB V8.X.


On Z/OS it doesnot work. IBM material also speaks the same.

Thanks,
Jayanta Datta
New Delhi
Reply With Quote
  #11 (permalink)  
Old 05-31-06, 09:23
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Yes I realize that all these solutions don't work for z/os

Thanks again big blue

And dig this...I just found that the business requires a cloumn to be enlarged.

I have 50 sprocs that have to be changed...or hopefully they are just in Cursors, but then that means the front end has to change
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #12 (permalink)  
Old 06-01-06, 02:50
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Quote:
Originally Posted by Brett Kaiser
Yes I realize that all these solutions don't work for z/os
I share your feelings. I used to work on DB2 8.2 on Windows and AIX, and all the things I took for granted all of a sudden don't work anymore.

Do you have an alternative DB2 infocenter site for mainframe DB2 ?
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #13 (permalink)  
Old 06-01-06, 03:06
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by Brett Kaiser
Yes I realize that all these solutions don't work for z/os

Thanks again big blue

And dig this...I just found that the business requires a cloumn to be enlarged.

I have 50 sprocs that have to be changed...or hopefully they are just in Cursors, but then that means the front end has to change
Sounds to me like you are a lazy crybaby.

There are tools from BMC and Platinum (CA) that will do what you want that IBM helped fund and promote when they were developed by these IBM Business Partners more than 15 years ago.
__________________
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
  #14 (permalink)  
Old 06-02-06, 16:08
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by Wim
Do you have an alternative DB2 infocenter site for mainframe DB2 ?
Sure: infocenter DB2 v8 for z/OS
__________________
--_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
  #15 (permalink)  
Old 06-02-06, 16:13
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by grofaty
CALL SYSPROC.ALTOBJ (...)
Are you sure that related objects (VIEWs, PLANs, ...) are not affected by this surrogate ALTER 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
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