ORA-02270:此列列表没有匹配的唯一键或主键

时间:2014-02-13 10:31:10

标签: sql oracle sqlplus

我使用iSQLPlus创建表格,当我引用多个外键时,它们会给我错误ORA-02270

ORA-02270: no matching unique or primary key for this column-list 

这是我的代码:

create table People
(name varchar(50),
ssn varchar(50) not null,
G# varchar(50),
primary key (ssn),
unique(ssn, G#))

create table Professor
(
name varchar(50),
ssn varchar(50) not null,
G# varchar(50),
teach_record varchar(50),
primary key (ssn),
unique (ssn, G#),
foreign key (name, ssn, G#) references People(name, ssn, G#) ON DELETE CASCADE
)

它表示教授脚本中“)”之前的行上的错误,该脚本引用了People(name,ssn,G#) 我无法想象问题是什么。

1 个答案:

答案 0 :(得分:2)

试试这个:

create table People
(name varchar(50),
ssn varchar(50) not null,
G# varchar(50),
primary key (ssn),
unique(name, ssn, G#))

create table Professor
(
name varchar(50),
ssn varchar(50) not null,
G# varchar(50),
teach_record varchar(50),
primary key (ssn),
unique (ssn, G#),
foreign key (name, ssn, G#) references People(name, ssn, G#) ON DELETE CASCADE
)