If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Hey guys I have another quick question?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-12, 22:21
Jsin Jsin is offline
Registered User
 
Join Date: Jan 2012
Posts: 16
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 22:53. Reason: added to much
Reply With Quote
  #2 (permalink)  
Old 01-27-12, 22:52
Jsin Jsin is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 01-27-12, 23:15
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
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.
Reply With Quote
  #4 (permalink)  
Old 01-27-12, 23:30
Jsin Jsin is offline
Registered User
 
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);
Reply With Quote
  #5 (permalink)  
Old 01-27-12, 23:37
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
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.
Reply With Quote
  #6 (permalink)  
Old 01-27-12, 23:45
Jsin Jsin is offline
Registered User
 
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?
Reply With Quote
  #7 (permalink)  
Old 01-27-12, 23:53
Jsin Jsin is offline
Registered User
 
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,
Reply With Quote
  #8 (permalink)  
Old 01-28-12, 00:06
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On