善哉善哉 发表于 2010-4-1 20:29

求助SQL问题

create table s1
(sno char(8) not null,
sname char(10),
ssex char(2)
)
alter table s1
add constraint pk_sno primary key(sno)
alter table s1
add constraint uk_cno unique(sname)
alter table s1
add constraint df1_ssex default'男'for ssex
create table c1
(sno char(8) not null,
cno char(8) not null,
score int
)
alter table c1
add constraint pk_c1 primary key(sno)
alter table c1
add constraint pk_c2 primary key(cno)
alter table c1
add constraint fk_sno foreign key references s1(sno)
alter table c1
add constraint score_chk check(score>=0 and score<=100)

执行后出现
消息 8139,级别 16,状态 0,第 22 行
表 'c1' 的外键中引用列的数目与被引用列的数目不等。

kenzhong 发表于 2010-4-2 16:50

alter table c1
add constraint pk_c1 primary key(sno)
alter table c1
add constraint pk_c2 primary key(cno)
alter table c1
-------------------------》how could one table has two primary key??

kenzhong 发表于 2010-4-2 16:53

As far as i know that one table having two primary keycould never happen in Oracle!
页: [1]
查看完整版本: 求助SQL问题