MySQL建表设置外键提示错误

错误内容:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'references xx(xx)

原因:书写创建外键语句时,要设置为外键的列名没有加括号,正确写法如下:

alter table course add foreign key (cpno) references course(cno);

posted on 2013-09-09 18:55  hackem  阅读(475)  评论(0编辑  收藏  举报

导航