当前位置: 代码迷 >> Sql Server >> 創建表失敗解决方案
  详细解决方案

創建表失敗解决方案

热度:70   发布时间:2016-04-27 20:53:08.0
創建表失敗
執行下面的SQL語句創建表失敗,請問各位該如何解決?謝謝!!

CREATE   table   enrolls
(sno   numeric(6,0)   not   null,
cno   char(4)   not   null,
grade   int  
primary   key   (sno,cno)
foreign   key   (sno)   references   students(sno)
foreign   key   (cno)   references   courses(cno)
check((grade   is   null)or(grade   between   0   and   100)))

錯誤提示:More   than   one   column   FOREIGN   KEY   constraint   specified   for   column   'grade ',   table   'enrolls '.        


------解决方案--------------------
CREATE table enrolls
(sno numeric(6,0) not null,
cno char(4) not null,
grade int ,
primary key (sno,cno),
foreign key (sno) references students(sno),
foreign key (cno) references courses(cno),
check((grade is null)or(grade between 0 and 100)))
------解决方案--------------------
...豆号
------解决方案--------------------
‘,’逗号,不加的话,就把后面的约束全当成是grade字段的了,自然就more than...了
  相关解决方案