ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

need SQL script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • need SQL script

    I need an SQL script to add a foreign key constraint on table 1
    to make sure that cntcod(country code) of table1 must exist in table2.

    Please help posting code!

    Donna

  • #2
    Re: need SQL script

    Code:
    ALTER TABLE lib/table1
      ADD FOREIGN KEY (CNTCOD)
         REFERENCES lib/table1 (fldnam)
         ON DELETE RESTRICT
         ON UPDATE RESTRICT
    Or something like that. I wouldn't know for sure 'cause I've never done this before. Then how did I come up with this syntax, you ask? I just went into STRSQL and typed ALTER TABLE and press the F4 key for prompt. I guessed at the rest.
    "Time passes, but sometimes it beats the <crap> out of you as it goes."

    Comment


    • #3
      Re: need SQL script

      Thanks!

      I got it.

      Comment

      Working...
      X