Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2012
    Posts
    16

    Unanswered: Hey guys I have another quick question?

    I get a ORA-02264: name already used by an existing constraint with
    CONSTRAINT FKFid FOREIGN KEY (Fid) REFERENCES FACULITY,

    Here is the table I am trying to create.


    CREATE TABLE COURSE_SECTION
    ( Csecid NUMBER(8) CONSTRAINT PKCOURSE_SECTION PRIMARY KEY,
    Cid NUMBER(6) NOT NULL,
    Termid NUMBER(5) NOT NULL,
    Secnum NUMBER(2) NOT NULL,
    Fid NUMBER(4),
    Day VARCHAR2(10),
    Locid NUMBER(5),
    Maxenrl NUMBER(4) NOT NULL,
    Currenrl NUMBER(4) NOT NULL,
    CONSTRAINT FKCid FOREIGN KEY (Cid) REFERENCES COURSE,
    CONSTRAINT FKTermid FOREIGN KEY (Termid) REFERENCES TERM,
    CONSTRAINT FKFid FOREIGN KEY (Fid) REFERENCES FACULITY,
    CONSTRAINT FKLocid FOREIGN KEY (Locid) REFERENCES LOCATION);

    Once again I have tried a few different things but nothing works, any advice?

    Thanks.
    Last edited by Jsin; 01-27-12 at 23:53. Reason: added to much

  2. #2
    Join Date
    Jan 2012
    Posts
    16

    Sorry let me clean this up a little.

    Is it possible I am getting this error because I'm using it as a foreign key in another table, but that doesn't really make sense to me either.

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    select owner, table_name, constraint_type from all_constraints where constraint_name = 'FKFID';
    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.

  4. #4
    Join Date
    Jan 2012
    Posts
    16
    Quote Originally Posted by anacedent View Post
    select owner, table_name, constraint_type from all_constraints where constraint_name = 'FKFID';


    I'm sorry but I don't really follow this is the other table that uses Fid

    CREATE TABLE STUDENT
    ( Sid NUMBER(5) CONSTRAINT PKSTUDENT PRIMARY KEY,
    Slname VARCHAR2(25) NOT NULL,
    Sfname VARCHAR2(25) NOT NULL,
    Smi CHAR,
    Saddr VARCHAR(30),
    Scity VARCHAR(30),
    Sstate CHAR(2) DEFAULT 'WI',
    Szip NUMBER(9),
    Sphone NUMBER(10) NOT NULL,
    Sclass CHAR(2) CONSTRAINT Sclass CHECK( Sclass = 'FR' OR Sclass = 'GR' OR Sclass = 'JR' OR Sclass = 'SO' OR Sclass = 'SR'),
    Sdob DATE NOT NULL,
    S_pin NUMBER(4) NOT NULL,
    Fid NUMBER(4),
    CONSTRAINT FKFid FOREIGN KEY (Fid) REFERENCES FACULITY);

    so then are you saying I write it like this:

    SELECT STUDENT, CONSTRAINT FKFid FOREIGN KEY (Fid) REFERENCES FACULITY);

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    you can not have two constraints with the same name, "FKFID"
    change the name of one of the constraint to be a different name.
    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.

  6. #6
    Join Date
    Jan 2012
    Posts
    16
    Quote Originally Posted by anacedent View Post
    you can not have two constraints with the same name, "FKFID"
    change the name of one of the constraint to be a different name.
    That worked thank you so much. So what I did was Name it FKFID2.. and it worked. My next question is there some kind of syntax or naming convention that is normally followed, that maybe I overlooked in my reading assignment?

  7. #7
    Join Date
    Jan 2012
    Posts
    16
    So after a little more looking up and putting 2 and 2 together, what you said at first makes sense to me now.

    I should have named it something like this

    CONSTRAINT COURSE_SECTION_FidFK FOREIGN KEY (Fid) REFERENCES FACUILTY,

  8. #8
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can name the constraint anything you desire.
    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.

Posting Permissions

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