我有两张桌子:entitytype张和project张.以下是CREATE TABLE语句:
Create table project (
pname varchar(20) not null,
primary key(pname)
);
create table entitytype(
entityname varchar(20) not null,
toppos char(100),
leftpos char(100),
pname varchar(20) not null,
primary key(entityname),
foreign key(pname) references project(pname) on delete cascade on update cascade
);
当我try 将任何值插入到entitytype表中时,我得到以下错误:
ERROR: insert or update on table "entitytype" violates foreign key constraint "entitytype_pname_fkey"
Detail: Key (pname)=(494) is not present in table "project".
有谁能说明我做错了什么吗?