Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    149

    Unanswered: DROP Column Or Add a NOT NULL Constraint

    Hi- I am new to the DB2 world. I wanted to add a not null column with a default to an existing table with data. Not realizing I could do that, I added the column as a Nullable column, updated the existing data. Now I need to add a NOT NULL constraint. Could I do that? If not, I would like to DROP the column. I tried the syntax
    ALTER TABLE <tableName> DROP COLUMN <columnName>.

    I get an error "SQL0104N An unexpected token "C_CNTR_VST_FR_SFE" was found following "". Expected tokens may include: "KEY "."

    Any help is greatly appreciated.

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Three options :

    a) Export data, drop table, create table with the proper defn and load data

    b) Use Control Centre to ALTER - Assuming you are 8.2+ (always mention your version and OS) , all steps in option a is done behing the scenes.

    c) Add a NOT NULL CHECK Constraint on the column
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    149
    Thanks Satya. Did not realize I could not DROP a column. That is kinda interesting. I will try the option A.

    Thanks for your time again.

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by sbaru
    Thanks Satya. Did not realize I could not DROP a column.
    There is no "alter table drop column" in the SQL Reference manual.
    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
  •