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 > problem with alter table command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-05-09, 14:08
abishek.n abishek.n is offline
Registered User
 
Join Date: May 2009
Posts: 6
Red face problem with alter table command

I am trying to drop a column from the table ASSOCIATED_PAGE_QUESTION and I give the following command
ALTER TABLE ASSOCIATED_PAGE_QUESTION DROP COLUMN question_name

There are no constrains associated to this column however this gives me the following error

ALTER TABLE ASSOCIATED_PAGE_QUESTION DROP COLUMN question_name
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "COLUMN" was found following "D_PAGE_QUESTION
DROP". Expected tokens may include: "CONSTRAINT". SQLSTATE=42601

Can someone help me out
Reply With Quote
  #2 (permalink)  
Old 05-05-09, 14:37
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What DB2 version and OS?

Andy
Reply With Quote
  #3 (permalink)  
Old 05-05-09, 15:09
abishek.n abishek.n is offline
Registered User
 
Join Date: May 2009
Posts: 6
Thanks for responding Andy,
its IBM DB2 Universal Database 8 FP 6a
Reply With Quote
  #4 (permalink)  
Old 05-05-09, 15:10
abishek.n abishek.n is offline
Registered User
 
Join Date: May 2009
Posts: 6
and the OS is AIX 5.3
Reply With Quote
  #5 (permalink)  
Old 05-05-09, 15:12
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
ALTER TABLE ... DROP COLUMN is a new feature starting at V 9.1.

That is why you are getting the error.

Andy
Reply With Quote
  #6 (permalink)  
Old 05-05-09, 15:16
abishek.n abishek.n is offline
Registered User
 
Join Date: May 2009
Posts: 6
Ohh thanks .. so is there an alternative way to do this? I am searching online as well
Reply With Quote
  #7 (permalink)  
Old 05-05-09, 15:16
abishek.n abishek.n is offline
Registered User
 
Join Date: May 2009
Posts: 6
also is there a way to rename a column?
Reply With Quote
  #8 (permalink)  
Old 05-05-09, 15:18
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
1. drop and rebuild the table

2. create a view to rename this column

3. upgrade
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #9 (permalink)  
Old 05-05-09, 15:48
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
There is altobj that you can use to drop/rename the column, but I believe it's only available starting with v8 fp7:
DB2 Universal Database

altojb has some problems so consider upgrading to the latest fixpak if you're going to use it.
Reply With Quote
  #10 (permalink)  
Old 05-07-09, 18:20
abishek.n abishek.n is offline
Registered User
 
Join Date: May 2009
Posts: 6
Thanks for all ur inputs.. I got the DBA to drop the table and create a newone.
Reply With Quote
  #11 (permalink)  
Old 05-08-09, 10:11
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Quote:
Originally Posted by abishek.n
Thanks for all ur inputs.. I got the DBA to drop the table and create a newone.
Did you get him a doughnut? It will help you in the future
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
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