DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: check constraint

  1. #1
    Join Date
    Jan 2001
    Posts
    157

    Thumbs down

    How do you modify a check constraint?
    I have 5 check constraints on a column. I want to add 2 more constraints to the column to make the total check constraints on that column 7.
    How do I do that?

  2. #2
    Join Date
    May 2000
    Location
    Portsmouth, NH, USA
    Posts
    378

    alter table add constraint

    so:

    ALTER TABLE table_name
    ADD CONSTRAINT constraint_name
    CHECK (condition);

    okay?

    - Magnus

  3. #3
    Join Date
    Jan 2001
    Posts
    157

    You miss read my question.

    I already have this check constraint:
    ALTER TABLE table_name
    ADD CONSTRAINT constraint_name
    CHECK (column_name in (1,2,3,4,5,));

    Now I would like to add 7and 8 to it(so that it would look like this 1,2,3,4,5,6,7,8) how do I do that?

  4. #4
    Join Date
    Nov 2000
    Posts
    344
    Just drop and recreate the constraint,
    like this :

    alter table table_name
    drop contstraint constraint_name;

    alter table table_name
    add constraint constraint_name
    .....;
    John Dorlon
    www.ezsql.net
    john@ezsql.net

  5. #5
    Join Date
    Aug 2000
    Posts
    462
    alter table table_name drop constraint my_constraint;

    alter table table_name add constraint my_constraint(check mycol in (1,2,3,4,5,6,7,8));

    Oracle DBA and Developer

  6. #6
    Join Date
    Jan 2001
    Posts
    157
    If the table is loaded with data, would there be a problem dropping and recreating the check constraint?

  7. #7
    Join Date
    Aug 2000
    Posts
    17
    Hmmm, not really a problem but:

    Between the drop and the recreate no check constraint is active...

    When recreating the check constraint the table is locked until all the data is checked again...

    Roger

Posting Permissions

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


Click Here to Expand Forum to Full Width