Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    205

    Unanswered: check constraints ?

    Is there any CHECK constraint syntax as below in Oracle ?

    CONSTRAINT DATE_INTERVAL CHECK (end_date > start_date, END_DATE)

    Please advise.

    Thanks,
    Sam

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    What does your constraint mean? You can certainly do this:

    CONSTRAINT DATE_INTERVAL CHECK (end_date > start_date)

    But I don't know what you intended by the extra ", END_DATE" part.

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    SamCute, did you - putting END_DATE into your example - mean that this is a column constraint? I forgot what DB you use; perhaps there you can do it. But, in Oracle you'd get "ORA-02438: Column check constraint cannot reference other columns" error which means that check constraint that references other column must be a table constraint.

    Finally, the syntax would be

    alter table mytable
    add constraint ch_date_interval
    check (end_date > start_date);

  4. #4
    Join Date
    Mar 2004
    Posts
    205
    Yes its a column constraint in CREATE TABLE statement

Posting Permissions

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