厦门马拉松赛事:sql 外码 引用

来源:百度文库 编辑:中科新闻网 时间:2024/05/04 19:09:32
create table chapter(
chapter_ID int not null ,
chapter_name varchar(50) not null,
Sub_ID int not null,
primary key(chapter_ID,Sub_ID),
foreign key(Sub_ID)
references subjectinfo(Sub_ID)--章节因用科目ID,,
)
--试题
create table test_paper(
test_ID int not null ,--题号
Sub_ID int not null,
test_content varchar(50) not null,
test_answer varchar(50) not null,
test_true_answer char(4) not null,
test_diff_degree int not null,
chapter_ID int not null,
T_AD_ID char(8) not null ,
test_typeID int not null ,--题型ID
parse varchar(1000),
primary key(test_ID),
foreign key(chapter_ID)
references chapter(chapter_ID,Sub_ID),
foreign key(T_AD_ID)
references storagemanage(T_AD_ID),
foreign key(test_typeID)
references testtype(test_typeID),
)
其他表都齐全.这两个表引用时出现错误如下:
服务器: 消息 8139,级别 16,状态 1,行 1
外键中引用列的数目与被引用列的数目不等,表 'test_paper'。