以下是代码:
DROP TABLE FILM CASCADE CONSTRAINTS;
DROP TABLE COMPANY CASCADE CONSTRAINTS;
DROP TABLE MAIN_ACTOR CASCADE CONSTRAINTS;
DROP TABLE DIRECTOR CASCADE CONSTRAINTS;
CREATE TABLE FILM (
Film_ID NUMBER(4) PRIMARY KEY,
Title VARCHAR2(35) NOT NULL,
Year Date NOT NULL,
Language VARCHAR2(20),
Director_ID NUMBER(4) NOT NULL,
Actor_ID NUMBER(4) NOT NULL,
Company_ID NUMBER(4) NOT NULL,
Genre NUMBER(4) NOT NULL,
FOREIGN KEY (Director_ID) REFERENCES DIRECTOR(Director_ID),
FOREIGN KEY (Actor_ID) REFERENCES MAIN_ACTOR(Main_Actor_ID),
FOREIGN KEY (Company_ID) REFERENCES COMPANY(Company_ID)
);
CREATE TABLE COMPANY (
Company_ID NUMBER(4) PRIMARY KEY,
Company_Name VARCHAR2(20) NOT NULL,
Company_Country VARCHAR2(20) NOT NULL
);
CREATE TABLE MAIN_ACTOR (
Main_Actor_ID NUMBER(4) PRIMARY KEY,
First_Name VARCHAR2(20) NOT NULL,
Last_Name VARCHAR2(20) NOT NULL,
Birthday Date NOT NULL,
Country VARCHAR2(20)
);
CREATE TABLE DIRECTOR (
Director_ID NUMBER(4) PRIMARY KEY,
Director_First_Name VARCHAR2(20),
Director_Last_Name VARCHAR2(20) NOT NULL,
Director_BD Date,
Country VARCHAR2(20) NOT NULL
);
我得到的错误是:
Line 6
Error report -
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
所以我搜索了一下,但我一无所获。当您使用错误的权限调用select时,似乎发生了所有这样的错误,但是在 CREATE TABLE 上的简单调用中,这给了我这个错误。
所以我试图放弃它并最终重新创建但没有改变。
答案 0 :(得分:0)
您在外部约束中引用未创建的表,因此请更改序列。
没有外来约束的第一个表以及引用这些表的表之后
DROP TABLE FILM CASCADE CONSTRAINTS;
DROP TABLE COMPANY CASCADE CONSTRAINTS;
DROP TABLE MAIN_ACTOR CASCADE CONSTRAINTS;
DROP TABLE DIRECTOR CASCADE CONSTRAINTS;
CREATE TABLE DIRECTOR (
Director_ID NUMBER(4) PRIMARY KEY,
Director_First_Name VARCHAR2(20),
Director_Last_Name VARCHAR2(20) NOT NULL,
Director_BD Date,
Country VARCHAR2(20) NOT NULL
);
CREATE TABLE MAIN_ACTOR (
Main_Actor_ID NUMBER(4) PRIMARY KEY,
First_Name VARCHAR2(20) NOT NULL,
Last_Name VARCHAR2(20) NOT NULL,
Birthday Date NOT NULL,
Country VARCHAR2(20)
);
CREATE TABLE COMPANY (
Company_ID NUMBER(4) PRIMARY KEY,
Company_Name VARCHAR2(20) NOT NULL,
Company_Country VARCHAR2(20) NOT NULL
);
CREATE TABLE FILM (
Film_ID NUMBER(4) PRIMARY KEY,
Title VARCHAR2(35) NOT NULL,
Year Date NOT NULL,
Language VARCHAR2(20),
Director_ID NUMBER(4) NOT NULL,
Actor_ID NUMBER(4) NOT NULL,
Company_ID NUMBER(4) NOT NULL,
Genre NUMBER(4) NOT NULL,
FOREIGN KEY (Director_ID) REFERENCES DIRECTOR(Director_ID),
FOREIGN KEY (Actor_ID) REFERENCES MAIN_ACTOR(Main_Actor_ID),
FOREIGN KEY (Company_ID) REFERENCES COMPANY(Company_ID)
);
答案 1 :(得分:0)
由于您在drop查询中级联到约束,因此Director_ID,ACTOR_ID和Company_ID的外键约束已受到影响,并且还删除了那些表,FILM表的Create query无法找到要链接的其他表外国钥匙。您需要从下到上运行CREATE查询,以便最后创建具有FOREIGN KEYS到其他表的FILM表,并重新建立REFERENTIAL KEYS。