Results 1 to 5 of 5

Thread: Char Vs Varchar

  1. #1
    Join Date
    Jun 2004
    Posts
    38

    Unanswered: 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.

  2. #2
    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

  3. #3
    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

  4. #4
    Join Date
    Jun 2004
    Posts
    38
    I'm using DB2 UDB V8.2 under AIX 5.3

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •