create table classroom (building varchar(15), room_number varchar(7), capacity number(4,0), primary key (building, room_number) ); create table department (dept_name varchar(20), building varchar(15), budget number(12,2) check (budget > 0), primary key (dept_name) ); create table course (course_id varchar(5), title varchar(50), dept_name varchar(20), credits number(2,0) check (credits > 0), primary key (course_id), foreign key (dept_name) references department on delete set null );
时间: 2023-06-17 14:03:43 浏览: 305
这是三个关系表的创建语句,分别是教室表(classroom)、学院表(department)和课程表(course)。其中教室表和学院表都有主键,而课程表除了主键(course_id)还有一个外键(dept_name),引用了学院表的主键(dept_name),并且在删除学院表中的某条记录时,与之对应的课程表中的dept_name会被设置为null。表中的字段类型和约束条件都有明确的定义。
阅读全文