what is wrong with my query?



  • CREATE TABLE Match(
    MId INTEGER,
    TId INTEGER CONSTRAINT tid_fk REFERENCES Match(TId),
    Player1 INTEGER CONSTRAINT pl1_fk REFERENCES Match(Player1),
    Player2 INTEGER CONSTRAINT pl2_fk REFERENCES Match(Player2),
    CHECK (Player1<>Player2),
    MatchDt DATE NOT NULL,
    Winner INTEGER CONSTRAINT wnnr_fk REFERENCES Match(Winner),
    Score VARCHAR2(30) NOT NULL,
    CONSTRAINT Id_pk PRIMARY KEY(MId,TId)
    );
    


  • You forgot the "foreign key", and you can only reference primary or unique keys.

    eg. https://www.oracletutorial.com/oracle-basics/oracle-foreign-key/

    BTW, I've never seen a column reference itself.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2