我刚启动sql,但是在创建带有外键的表时遇到了麻烦。 我毫不费力地创建了父表,但是似乎无法弄清楚,有什么帮助吗?谢谢
父表:
Create table instructor(
InstructorName varchar(255) not null primary key,
instructoremaill varchar(255) not null,
biography varchar(255) not null,
specialty varchar(255) not null
);
给我带来麻烦的代码。我正在尝试创建一个表,如果从数据库中删除了讲师,它将删除所有会话
Create table timetable(
number(10) not null,
dayandtime string not null,
numberofplaces number(10) not null,
classname varchar(255) not null,
venuename varchar(255) not null,
primary key (sessionid),
Constraint fk_instructorname
foreign key (instructorname)REFERENCES instructor(instructorname)
on delete cascade
);
答案 0 :(得分:0)
表时间表需要进行以下更改
number(10) not null- missing column name
dayandtime string not null- No string datatype in oracle
primary key (sessionid) - should be like sessionid number primary key
Constraint fk_instructorname - There is missing of column instructorname definition (InstructorName varchar(255) not null)
-新表的DDL
Create table timetable(
col1 number(10) not null,
dayandtime varchar2(255) not null,
numberofplaces number(10) not null,
InstructorName varchar(255) not null,
classname varchar(255) not null,
venuename varchar(255) not null,
sessionid number primary key,
Constraint fk_instructorname
foreign key (instructorname) REFERENCES instructor(instructorname)
on delete cascade);