我使用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#) 我无法想象问题是什么。
答案 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
)