Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Unanswered: Altering null column to Not Null

    Hi,

    I have a column which is of type varchar, I want to alter to make it not nullable.

    This column is part of unique key.

    Please advice how can i do that.

    Thanks

  2. #2
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    Always post your DB2-server version and fixpack...

    Refer to ALTER TABLE - IBM DB2 9.7 for Linux, UNIX, and Windows

  3. #3
    Join Date
    Apr 2012
    Posts
    3

    Altering null column to Not Null

    I tried something like below,

    ALTER TABLE rxqhrdr.resource_governance Alter column SUBJECT_GUID not null;

    It works in derby, same command doesn't work in DB2 when i run from dbvisualizer.

    Please advice whats wrong in this.

    I am using Db2v9.5.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    How about you post us the DB2 version and platform you are running it on? There are a few different DB2 products and they tend to have different scopes in terms of functionality.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    Apr 2012
    Posts
    3
    I was missing the set keyword, the below statement works just fine.

    ALTER TABLE rxqhrdr.resource_governance Alter column SUBJECT_GUID set not null;

    Thanks for your help.

  6. #6
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    Never say "it does'nt work" - always state *exactly* what the error-code and error-message that you receive.

  7. #7
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963
    You can only drop the old table with clm varchar(kk) NOT NULL and create the new one where clm varchar(nn) NOT NULL WITH DEFAULT, only .

    Don't forget to unload the old one table and load this data into the new created table.
    Last edited by Lenny77; 05-08-12 at 16:10.

Posting Permissions

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