--成绩表
create table Grade
(Sno varchar2(20) constraint S_CONS not null,--考号
 Sname nvarchar2(20) constraint S_CONS not null,--姓名
 Gpolitic smallint,--政治
 Gforeign smallint,--外语
 Gbasic smallint,--基础科目
 Gmajorbasic smallint,--专业基础科目
 constraint G_PRIM Gmajor smallint,--专业科目
 constraint S_CONS primary key(Sno,Sname),
 constraint S_CONS foreign key (Sno) references Student(Sno),
 foreign key (Sname) references Student(Sname)
);错误:第12行出现错误:ORA-02270:此列表的唯一关键字或主键不匹配大侠帮帮忙啊,小弟谢过了

解决方案 »

  1.   

    你这个建表语句,怎么看着那么别扭啊。
    要那么多constraint干吗?
    create table Grade
    (Sno varchar2(20)  not null,--考号
     Sname nvarchar2(20)  not null,--姓名
     Gpolitic smallint,--政治
     Gforeign smallint,--外语
     Gbasic smallint,--基础科目
     Gmajorbasic smallint,--专业基础科目
     Gmajor smallint,--专业科目
     constraint S_CONS primary key(Sno,Sname),
     foreign key (Sno) references Student(Sno),
     foreign key (Sname) references Student(Sname)
    );你看这样能运行不?
      

  2.   

    貌似还是不行你看这是我的代码create table Student
    (Sno varchar2(20) not null, --考号
     Sname nvarchar2(20) not null,--姓名
     Ssex nvarchar2(4),--性别
     Sage smallint,--年龄
     Spolitic nvarchar2(10),--政治面貌
     Sfresh nvarchar2(4),--是否应届
     Seducation nvarchar2(10),--学历
     Sorigin nvarchar2(20),--来源
     Smajor nvarchar2(10),--报考专业
     Scategory nvarchar2(10)--报考类别
     constraint S_PRIM primary key(Sno,Sname)
    );--成绩表
    create table Grade
    (Sno varchar2(20) constraint S_CONS not null,--考号
     Sname nvarchar2(20) constraint S_CONS not null,--姓名
     Gpolitic smallint,--政治
     Gforeign smallint,--外语
     Gbasic smallint,--基础科目
     Gmajorbasic smallint,--专业基础科目
     Gmajor smallint,--专业科目
     constraint G_PRIM primary key(Sno,Sname),
     foreign key (Sno) references Student(Sno),
     foreign key (Sname) references Student(Sname)
    );
      

  3.   


    create table Grade
    (Sno varchar2(20)  not null,--考号
     Sname nvarchar2(20)  not null,--姓名
     Gpolitic smallint,--政治
     Gforeign smallint,--外语
     Gbasic smallint,--基础科目
     Gmajorbasic smallint,--专业基础科目
     Gmajor smallint,--专业科目
     constraint S_CONS primary key(Sno,Sname),
     constraint S_CONS1 foreign key (Sno) references Student(Sno),
     foreign key (Sname) references Student(Sname)
    )
    tablespace user;
      

  4.   


    create table Grade
    (Sno varchar2(20)  not null,--考号
     Sname nvarchar2(20)  not null,--姓名
     Gpolitic smallint,--政治
     Gforeign smallint,--外语
     Gbasic smallint,--基础科目
     Gmajorbasic smallint,--专业基础科目
     Gmajor smallint,--专业科目
     constraint S_CONS primary key(Sno,Sname),
     constraint S_CONS1_sno foreign key (Sno) references Student(Sno),
     constraint S_CONs1_sna foreign key (Sname) references Student(Sname)
    )
    tablespace user;
      

  5.   

    ORA-02270:
    no matching unique or primary key for this column-list
    Cause:  A REFERENCES clause in a CREATE/ALTER TABLE statement gives a column-list for which there is no matching unique or primary key constraint in the referenced table.
    Action:  Find the correct column names using the ALL_CONS_COLUMNS catalog view