-1

I got some help last night on this code but now I am getting a different error. My professor is STILL not answering me so I am coming to you guys. Here is the code:

--Create Volunteer Supervisor

CREATE TABLE Volunteer_Supervisor
(
PH_Person_ID    Number(10)   NOT NULL,
EM_Person_ID    Number(10)    NOT NULL,
VO_Person_ID    Number(10)   NOT NULL,
End_Date    Date    NOT NULL,
Begin_Date  Date    NOT NULL,
Hours_Worked    Number(4)   NULL,
PWork_Unit_ID    Number(4)   NULL,
PRIMARY KEY (PWork_Unit_ID),
CONSTRAINT CCPHPersonID_FK FOREIGN KEY (PH_Person_ID) References Physician (PH_Person_ID),
CONSTRAINT CCEMPersonID_FK FOREIGN KEY (EM_Person_ID) References Employee (EM_Person_ID),
CONSTRAINT CCVOPersonID_FK FOREIGN KEY (VO_Person_ID) References Volunteer (VO_Person_ID),
CONSTRAINT CCPWorkUnitID_PK FOREIGN KEY (PWork_Unit_ID) References Work_Unit (PWork_Unit_ID)
);

Now I have changed the names but still getting this error:

Error report -

ORA-00955: name is already used by an existing object

  1. 00000 - "name is already used by an existing object" *Cause:
    *Action:

What am I missing?

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
  • looks like the constraints are still existing from previous attempts to create that table. predelete everything related to that table, before you attempt to create it again. or use the "CREATE OR REPLACE" syntax. – Cee McSharpface Apr 04 '20 at 20:34
  • @CeeMcSharpface so delete everything and replace "create table" with "replace table"? – Dominique Connor Apr 04 '20 at 20:42
  • sorry. looked it up. `DROP TABLE`, `CREATE TABLE`, `ALTER TABLE`. https://community.oracle.com/thread/944108?start=0&tstart=0 – Cee McSharpface Apr 04 '20 at 20:44
  • In oracle there's no 'replace table', or even 'create or replace table'. If you drop the table, all constraints are also dropped. So just insure that you really dropped it. – gsalem Apr 04 '20 at 20:44
  • If you're sure the table doesn't exist yet, check the constraints too. The constraint names have to be unique within your schema, as well as the table name; perhaps you have another table that has used the same constrain names? Try to use a naming scheme that prevents potential clashes. – Alex Poole Apr 04 '20 at 20:56

1 Answers1

0

If you are sure that no such table Volunteer_Supervisor exists, You may try below code -

CREATE TABLE Volunteer_Supervisor
(
PH_Person_ID    Number(10)   NOT NULL,
EM_Person_ID    Number(10)    NOT NULL,
VO_Person_ID    Number(10)   NOT NULL,
End_Date    Date    NOT NULL,
Begin_Date  Date    NOT NULL,
Hours_Worked    Number(4)   NULL,
PWork_Unit_ID    Number(4)   NULL,
PRIMARY KEY (PWork_Unit_ID),
FOREIGN KEY (PH_Person_ID) References Physician (PH_Person_ID),
FOREIGN KEY (EM_Person_ID) References Employee (EM_Person_ID),
FOREIGN KEY (VO_Person_ID) References Volunteer (VO_Person_ID),
FOREIGN KEY (PWork_Unit_ID) References Work_Unit (PWork_Unit_ID)
);
Ankit Bajpai
  • 13,128
  • 4
  • 25
  • 40