Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2010
    Posts
    9

    Unanswered: Trying to add constraints

    Hi,

    I've consulted the forum, documentation, the internet and text books but cannot find the correct SQL command to add constraints to an existing table

    Obviously I would

    ALTER TABLE Turkey ADD CONSTRAINT Whitemeat

    But what comes next is puzzling, the values of column Whitemeat can be any value other than Dinner, Gravy, Pumpkin, or Sauce

    Any assistance would be great

    Thank You

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Jan 2010
    Posts
    9
    Thanks, I've been there. There are no examples of applying check constraints

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jan 2010
    Posts
    9
    Thank for all the feedback

    ALTER TABLE TURKEY
    (CONSTRAINT TURKEY_WHITEMEAT_CK CHECK DEPT_ID NOT IN ('Dinner', 'Gravy', 'Pumpkin', 'Sauce'));

    According to the docs should be working, but I'm not getting anywhere

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >According to the docs should be working, but I'm not getting anywhere


    My car should be going but it is not getting anywhere.
    Please tell me how to make my car go.

    BTW - why are you checking DEPT_ID?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by maxheadwound View Post
    According to the docs should be working, but I'm not getting anywhere
    And the error message is....

  8. #8
    Join Date
    Jan 2010
    Posts
    9
    Hi,

    Thanks

    The error I am getting is "Missing Left Parenthesis"

    And I thought this was a forum for help anacedane?
    Last edited by maxheadwound; 01-22-10 at 17:25.

  9. #9
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by maxheadwound View Post
    The error I am getting is "Missing Left Parenthesis"
    You should have had a closer look a the manual
    Code:
    ALTER TABLE TURKEY
      ADD CONSTRAINT TURKEY_WHITEMEAT_CK 
          CHECK (DEPT_ID NOT IN ('Dinner', 'Gravy', 'Pumpkin', 'Sauce'));
    Are you sure a column called DEPT_ID may contain character values????

    Just looking at the column name, this sure sounds like a very strange thing to do.

  10. #10
    Join Date
    Jan 2010
    Posts
    9
    Thanks, I just figured that out. What online Oracle documentation to you use?

  11. #11
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  12. #12
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by maxheadwound View Post
    What online Oracle documentation to you use?
    The one that beilstwh and anacedent have already posted

  13. #13
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    The documentation was probably fine, but the reader was unable to properly read it.

Posting Permissions

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