create table Course (Cno char(4) primary key,Cname char(40),Cpno char(4),Ccredit smallint,foreign key Cpno references Course(Cno));
执行后显示
消息 102,级别 15,状态 1,第 1 行
'Cpno' 附近有语法错误。
该怎么改呢
------解决方案--------------------
------解决方案--------------------
就是在Cpno 前后加()
------解决方案--------------------
- SQL code
create table Course (Cno char(4) primary key, Cname char(40), Cpno char(4) constraint fk_cpno foreign key references Course(Cno), Ccredit smallint)
------解决方案--------------------
create table Course (
Cno char(4) primary key,
Cname char(40),
Cpno char(4) references Course(Cno),Ccredit smallint,
)
------解决方案--------------------
- SQL code
create table Course (Cno char(4) primary key,Cname char(40),Cpno char(4),Ccredit smallint,foreign key [color=#FF0000](Cpno)[/color] references Course(Cno));