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 > Agnostic column alter?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-13-07, 09:51
e1designs e1designs is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
Agnostic column alter?

Anyone have an agnostic way to alter a columns type...simply the size...?
Reply With Quote
  #2 (permalink)  
Old 12-13-07, 09:54
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
What do you want to do?

There is an ALTER TABLE statement for that:
Code:
ALTER TABLE ... ALTER COLUMN ... SET DATA TYPE ...
Certain restrictions apply, however. Check the manual of the DB2 version you are using (depending on your platform).
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 12-13-07, 10:31
e1designs e1designs is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
I am trying to alter the column size, from 256 to 1024, but I want the sql stmt to work on mysql...postgres...etc...agnostic?

so on postgres, this works...

alter table 'tablename' alter column 'column name' type varchar(1024);

but does not seem to work on mysql for instance...
Reply With Quote
  #4 (permalink)  
Old 12-13-07, 15:27
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
So you are interested in portable DDL syntax?

Since you are asking in a DB2 newsgroup, we can answer this question for DB2 (which is what I did).

For other systems, you will have to look at the respective manuals. I guess that your chances are pretty slim to find a consistent cross-product systax. For MySQL or PostgreSQL, you can actually change the product yourself or open a bug requesting that those products adopt a different syntax.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 12-13-07, 17:06
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
On DB2 V8, you can only increase the size of a varchar column online, you cannot decrease it. Not sure about V9.
__________________
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
  #6 (permalink)  
Old 12-14-07, 08:20
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Marcus_A,
on v9.5 Linux/Unix/Windows decrease of column size is also not possible.
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