求助:
建立外键总是报错error:1064,一直搞不明白。下面是代码:
create table course
(
cnum char(7) primary key,
cname char(20) not null,
chours smallint
);create table sc
(
snum char(9),
cnum char(7),
grade smallint default 0,
primary key (snum,cnum),
foreign key (cnum) course(cnum)
);建第二个表前面都是正确的,就是foreign key(cnum) course(cnum)这句一加上去就出错。。本人新手,求高手详细讲解。
建立外键总是报错error:1064,一直搞不明白。下面是代码:
create table course
(
cnum char(7) primary key,
cname char(20) not null,
chours smallint
);create table sc
(
snum char(9),
cnum char(7),
grade smallint default 0,
primary key (snum,cnum),
foreign key (cnum) course(cnum)
);建第二个表前面都是正确的,就是foreign key(cnum) course(cnum)这句一加上去就出错。。本人新手,求高手详细讲解。
[index_name] (index_col_name,...) reference_definition:
REFERENCES tbl_name (index_col_name,...)
[MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
[ON DELETE reference_option]
[ON UPDATE reference_option]
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html8、如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖
不好意思现在才回帖,昨天发了贴一直没有时间上网。
不是你说的那个错误。我在电脑上是按语法写的,发帖的时候写错了。。应该不是语法的错误,都试过很多遍了。还用书上的实例程序的试过都不行,别人电脑上就行,是不是mysql的一些配置会造成这种问题呢?