create table S(Sno CHAR(5) not null unique,Sname char(30) unique,Status char(8),City char(20) primary key (Sno));create table P(Pno char(6),Pname char(30) not null,Color char(8),Weight numeric(6,2),City char(20) primary key(Pno));create table SP(Sno char(5),Pno char(6),Status char(8),Qty numeric(9) primary key(Sno,Pno),foreign key(Sno) reference S(Sno), Foreign key (Pno) references P(Pno));这三行都缺啊。。

解决方案 »

  1.   

    缺少,号,多unique关键字,references写错create table S(Sno CHAR(5) not null  unique,Sname char(30) unique,Status char(8),City char(20) primary key (Sno));create table P(Pno char(6),Pname char(30) not null,Color char(8),Weight numeric(6,2),City char(20) , primary key(Pno));create table SP(Sno char(5),Pno char(6),Status char(8),Qty numeric(9) , primary key(Sno,Pno),foreign key(Sno) references S(Sno), Foreign key (Pno) references P(Pno));
      

  2.   

    把你的primary key 直接放到sno 的后面就行了。
    create table S(Sno CHAR(5) primary key,Sname char(30) ,Status char(8),City char(20));create table P(Pno char(6),Pname char(30) not null,Color char(8),Weight numeric(6,2),City char(20) , primary key(Pno));create table SP(Sno char(5),Pno char(6),Status char(8),Qty numeric(9) , primary key(Sno,Pno),foreign key(Sno) references S(Sno), Foreign key (Pno) references P(Pno));
      

  3.   


    create table S
    (Sno CHAR(5) not null,Sname char(30) unique,Status char(8),City char(20),
    constraint pk_sno primary key (Sno));create table P
    (Pno char(6),Pname char(30) not null,Color char(8),Weight numeric(6,2),City char(20),
    constraint pk_pno primary key(Pno));create table SP(Sno char(5),Pno char(6),Status char(8),Qty numeric(9),
    constraint pk_spno primary key(Sno,Pno),
    constraint fk_sno foreign key(Sno) references S(Sno),  ---少s
    constraint fk_pno Foreign key (Pno) references P(Pno));