View previous topic :: View next topic |
Author |
Message |
Lean Beginner
Joined: 07 Aug 2012 Posts: 37 Topics: 11
|
Posted: Fri Aug 22, 2014 9:56 pm Post subject: Can I drop multiple columns in DB2 |
|
|
i just want to drop the last three fields from a table, as following comments from IBM knowledge center.
To add a column, issue the following statement:
ALTER TABLE SALES
ADD COLUMN SOLD_QTY
SMALLINT NOT NULL DEFAULT 0
To delete or drop a column, issue the following statement:
ALTER TABLE SALES
DROP COLUMN SOLD_QTY
Can i try to drop multiple columns with following scripts.
Code: |
ALTER TABLE ABC
ADD COLUMN A SMALLINT NOT NULL DEFAULT 0
ADD COLUMN B SMALLINT NOT NULL DEFAULT 0
ADD COLUMN C SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE ABC
DROP COLUMN C
DROP COLUMN B
DROP COLUMN A;
|
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Sat Aug 23, 2014 6:42 pm Post subject: |
|
|
Lean,
AFAIK you can only drop 1 column at a time with ALTER command on z/OS. However you can drop the entire table and recreate the table without the columns you don't need which is a way of dropping more than 1 column at a time. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Lean Beginner
Joined: 07 Aug 2012 Posts: 37 Topics: 11
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Sun Aug 24, 2014 11:39 am Post subject: |
|
|
Lean,
The link is talking about AIX/WINDOWS. The DB2 version of z/OS is different from the open platform versions. On z/OS Drop column is supported in DB2 V11 which came out last September and AFAIK it only supports dropping a single column.
If you are concerned about reloading the table, then drop 1 column at a time and you wouldn't have to worry about unloading the data and then reloading it back again. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Lean Beginner
Joined: 07 Aug 2012 Posts: 37 Topics: 11
|
Posted: Sun Aug 24, 2014 8:34 pm Post subject: |
|
|
got it, thanks kolusu. |
|
Back to top |
|
|
|
|