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 > Char Vs Varchar

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-15-05, 07:10
ksolomon ksolomon is offline
Registered User
 
Join Date: Jun 2004
Posts: 38
Char Vs Varchar

Hello,

I'm able to increase the column length or a VARCHAR datatype column however when I tried to increase a CHAR datatype column it failes with an error message.
Whats the reason for this?

VARCHAR Example
CREATE TABLE VIN_FEC_FEL (FUEL_ECON_LABEL VARCHAR(3))
ALTER TABLE VIN_FEC_FEL ALTER COLUMN FUEL_ECON_LABEL SET DATA TYPE VARCHAR(10)

CHAR Example
CREATE TABLE VIN_FEC_FEL (FUEL_ECON_LABEL CHAR(3))
ALTER TABLE VIN_FEC_FEL ALTER COLUMN FUEL_ECON_LABEL SET DATA TYPE CHAR(10)
=> This alter statements fails...Why ?

Can't I increase a length of a CHAR datatype column?

Thanks,
Vij.
Reply With Quote
  #2 (permalink)  
Old 11-15-05, 07:48
sinwar sinwar is offline
Registered User
 
Join Date: Oct 2005
Location: pune(india)
Posts: 24
check with ur version of db2

Hi vij,

you didn't mention the db2 version you are using.As you can very well change the char-size in db2 v8 but not in db2 v7. For that you need to drop n recreate.

just check it out.

Sinwar
Reply With Quote
  #3 (permalink)  
Old 11-15-05, 09:48
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
resize

resizing is only possible for var fields
char fields would require more space to be pre-allocated and can only be done with unload-drop table - create table - import
same for V8
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
  #4 (permalink)  
Old 11-15-05, 21:52
ksolomon ksolomon is offline
Registered User
 
Join Date: Jun 2004
Posts: 38
I'm using DB2 UDB V8.2 under AIX 5.3
Reply With Quote
  #5 (permalink)  
Old 11-15-05, 23:05
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Read the manual for alter table. SQL Reference Vol 2.
__________________
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
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