Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2007
    Posts
    2

    Unanswered: Agnostic column alter?

    Anyone have an agnostic way to alter a columns type...simply the size...?

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

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

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

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

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605
    Marcus_A,
    on v9.5 Linux/Unix/Windows decrease of column size is also not possible.
    Grofaty

Posting Permissions

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