Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Posts
    11

    Unanswered: Alter Table Syntax

    I don't think this is possbile but I thought I would check. Is it possible to Alter a column from Nullable to Not Nullable w/o dropping and recreating the table? I'm coming a SQL Server background and there you can do the following....

    ALTER TABLE TABLENAME ALTER COLUMN CNAME NOT NULL

    As long as there are no values currently null in the table, this will work and is much faster than the alternative. Is there something that is similar or easier in DB2.

    Thanks

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    This kind of alteration is not possible in DB2 as far as I understand. Depending on why you need this you can add a check constraint:

    ALTER TABLE TABLENAME ADD CONSTRAINT T1C1 CHECK (CNAME IS NOT NULL)

Posting Permissions

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