Results 1 to 3 of 3

Thread: Ora-02270

  1. #1
    Join Date
    Jun 2012
    Posts
    2

    Unanswered: Ora-02270

    Hi guys,
    I am having a problem with this code:

    I have created this table :

    create table Interaute(
    email varchar(40),
    nom varchar(30),
    prenom varchar(30),
    region varchar(30),
    CONSTRAINT pk_email primary key(email)
    );

    and then when I wanted to create another table :

    create table Notation(
    idFilm integer,
    email varchar(40),
    note integer,
    CONSTRAINT pk_Notation primary key(idFilm,email),
    CONSTRAINT fk_NidFilm foreign key(idFilm) REFERENCES Film(idFilm),
    CONSTRAINT fk_email foreign key(email) REFERENCES Internaute(email)
    );
    and wanted to force entegrity among it, I am having this error :
    line 7:
    no matching unique or primary key for this column -list .
    i can't see where is the problem, because the primary key is already defined in
    Internaute.
    Could someone please help me?

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    First of all, you should learn that COPY/PASTE is the best option if you want to share what you did with us.

    You did not do that; because, the first statement creates the INTERAUTE table, but the second one is supposed to reference the INTERNAUTE table (which doesn't exist).

    Moreover, you are referencing the FILM table - does it exist? Because, if we remove that constraint (fk_NidFilm) and fix typos, both tables ARE created:
    Code:
    SQL> create table Internaute(
      2    email varchar(40),
      3    nom varchar(30),
      4    prenom varchar(30),
      5    region varchar(30),
      6    CONSTRAINT pk_email primary key(email)
      7  );
    
    Table created.
    
    SQL> create table Notation(
      2    idFilm integer,
      3    email varchar(40),
      4    note integer,
      5    CONSTRAINT pk_Notation primary key(idFilm,email),
      6    CONSTRAINT fk_NidFilm foreign key(idFilm) REFERENCES Film(idFilm),
      7    CONSTRAINT fk_email foreign key(email) REFERENCES Internaute(email)
      8  );
      CONSTRAINT fk_NidFilm foreign key(idFilm) REFERENCES Film(idFilm),
                                                           *
    ERROR at line 6:
    ORA-00942: table or view does not exist
    
    
    SQL> l6
      6*   CONSTRAINT fk_NidFilm foreign key(idFilm) REFERENCES Film(idFilm),
    SQL> c/const/-- const/
      6*   -- constRAINT fk_NidFilm foreign key(idFilm) REFERENCES Film(idFilm),
    SQL> l
      1  create table Notation(
      2    idFilm integer,
      3    email varchar(40),
      4    note integer,
      5    CONSTRAINT pk_Notation primary key(idFilm,email),
      6    -- constRAINT fk_NidFilm foreign key(idFilm) REFERENCES Film(idFilm),
      7    CONSTRAINT fk_email foreign key(email) REFERENCES Internaute(email)
      8* )
    SQL> /
    
    Table created.
    
    SQL>
    I presume that's the problem.
    Last edited by Littlefoot; 06-03-12 at 16:34. Reason: A typo spotted far too late.

  3. #3
    Join Date
    Jun 2012
    Posts
    2
    Thank you , that was the problem!

Posting Permissions

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