我正在尝试运行一个脚本,它只是一系列删除表和创建表。它可以编译,但运行时出现以下错误:ORA-00942 表或视图不存在。它们不应该存在我正在尝试创建它们!任何人都知道为什么会发生这种情况?我使用的是 Oracle 界面,而不是命令行。我在 Notepad++ 中创建了代码并将其上传到 Oracle。然后我在 Oracle 中保存并运行该脚本。当我单击查看结果时,会出现错误。
编辑:我现在注意到只有没有创建外键的表!
这是我的代码的摘录:
CREATE TABLE PricePlans (
plan_id NUMBER(3) NOT NULL,
plan_name VARCHAR2(15) NOT NULL,
plan_desc VARCHAR2(30) NOT NULL,
plan_duration_months NUMBER(2) NOT NULL,
plan_cost NUMBER(4) NOT NULL,
CONSTRAINT pk_planid PRIMARY KEY (plan_id)
);
DROP TABLE Classes;
CREATE TABLE Classes (
class_id NUMBER(3) NOT NULL,
class_name VARCHAR2(30) NOT NULL,
class_desc VARCHAR2(30) NOT NULL,
class_facility NUMBER(2) NOT NULL,
class_instructor NUMBER(5) NOT NULL,
class_cost NUMBER(2) NOT NULL,
CONSTRAINT pk_classid PRIMARY KEY (class_id),
CONSTRAINT fk_classfacility
FOREIGN KEY (class_facility)
REFERENCES Facilities(facility_id),
CONSTRAINT fk_classinstructor
FOREIGN KEY (class_instructor)
REFERENCES Employees(emp_id)
);
DROP TABLE Facilities;
CREATE TABLE Facilities (
facility_id NUMBER(2) NOT NULL,
facility_name VARCHAR(15) NOT NULL,
facility_manager NUMBER(4) NOT NULL,
CONSTRAINT pk_facilityid PRIMARY KEY (facility_id);
CONSTRAINT fk_facilitymanager
FOREIGN KEY (facility_manager)
REFERENCES Manager(manager_id)
);