create table project_supervisor (
supervisor_ID VARCHAR2 (5) Primary key,
last_name varchar2 (250),
other_names varchar2 (250)
);
CREATE TABLE Project_description
(
project_id VARCHAR2 NOT NULL,
project_title varchar,
project_summary varchar,
PRIMARY KEY (project_id),
FOREIGN KEY (supervisor_ID)
REFERENCES "project_supervisor" (supervisor_ID)
);
答案 0 :(得分:0)
create table project_supervisor (
supervisor_ID VARCHAR2 (5) Primary key,
last_name varchar2 (250),
other_names varchar2 (250)
);
CREATE TABLE Project_description
(
project_id VARCHAR2(100) NOT NULL,
project_title varchar(100),
project_summary varchar(100),
supervisor_ID varchar(5),
PRIMARY KEY (project_id),
FOREIGN KEY (supervisor_ID) REFERENCES project_supervisor (supervisor_ID)
);
答案 1 :(得分:0)
像这样创建它们:
CREATE TABLE project_supervisor (
supervisor_ID VARCHAR2 (5) Primary key,
last_name varchar2 (250),
other_names varchar2 (250)
);
CREATE TABLE Project_description (
project_id VARCHAR2(5) NOT NULL,
supervisor_ID varchar(5),
project_title varchar(25),
project_summary varchar(25),
CONSTRAINT pk_project_id PRIMARY KEY(project_id),
CONSTRAINT fk_supervisor_ID FOREIGN KEY(supervisor_ID)
REFERENCES project_supervisor (supervisor_ID)
);
varchar
列的长度。constraint
定义必须格式正确。supervisor_ID
列。project_supervisor
不应该被引用。答案 2 :(得分:0)
您需要在第二个表格中添加supervisor_ID
:
CREATE TABLE project_supervisor
(
supervisor_id VARCHAR2 (5) PRIMARY KEY,
last_name VARCHAR2 (250),
other_names VARCHAR2 (250)
);
CREATE TABLE project_description
(
project_id VARCHAR2 NOT NULL,
project_title VARCHAR,
project_summary VARCHAR,
supervisor_id VARCHAR2(5),
PRIMARY KEY (project_id),
FOREIGN KEY (supervisor_id) REFERENCES project_supervisor (supervisor_id)
);
此外,围绕表名不需要"
。