Home:ALL Converter>Trouble creating foreign key in Oracle create table

Trouble creating foreign key in Oracle create table

Ask Time:2013-11-22T02:40:44         Author:user2923395

Json Formatter

I'm building some really simple tables in Oracle and I'm having trouble creating foreign keys. The fac_ID in Equipment is the FK that references fac_ID in faculty, but it is creating an error.

I'm using Oracle 11g Express. When I run "select * from equipment" it produces the error " ORA-00942: table or view does not exist"

CREATE TABLE Faculty(
fac_ID        VARCHAR(10)    NOT NULL,
fac_Street    VARCHAR(70)    NOT NULL,
fac_City    VARCHAR(30)    NOT NULL,
fac_PROV    VARCHAR(2)    NOT NULL,
fac_Phone    VARCHAR(12)    NOT NULL,
PRIMARY KEY (fac_ID)
); 

CREATE TABLE Equipment(
equip_ID        VARCHAR(10)    NOT NULL,
fac_ID            VARCHAR(10)    NOT NULL,
equip_Name       VARCHAR(50)    NOT NULL,
equip_Quantity    VARCHAR(3)    NOT NULL,
equip_Purchase_Date    DATE    NOT NULL,
PRIMARY KEY (equip_ID),
CONSTRAINT fac_ID FOREIGN KEY (fac_ID) REFERENCES Faculty(fac_ID) 
); 

Author:user2923395,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20129329/trouble-creating-foreign-key-in-oracle-create-table
yy