sql - 引用表“Doctors”中没有与 FK 匹配的主键或候选键
问题描述
create table Doctors
(did numeric(3)
,description varchar(20)
,referral varchar(20)
,equipment varchar(10)
, primary key(did));
insert into Doctors values
(101,'physician','fever','medicines'),
(102,'physician','cold','tablet'),
(103,'physician','cough','syrup');
create table HCOReport
(serviceid numeric(3)
,IC numeric(10)
,DC numeric(10)
,referral varchar(20) references Doctors(referral)
,primary key(serviceid)
);
insert into HCOReport values
(201,200,300,'fever'),
(202,300,200,'cold'),
(203,200,283,'cold');
create table Inventory
(itemid numeric(10)
,serviceid numeric(3) references HCOReport(serviceid)
,supplier varchar(20)
,listOfSupplies varchar(30)
);
insert into Inventory values
(101,201,'Blue Ridge','medicines'),
(102,202,'Blue Ridge','stethoscope'),
(103,201,'Blue Ridge','equipment');
create table Patients
(pid numeric(3)
,Isinsurance varchar(3)
,cost numeric(10)
, primary key(pid)
);
insert into Patients values
(501,'yes',1000),
(502,'no',10000),
(504,'no',30000);
我不断得到
引用表 Doctors 中没有与外键“FK__HCOReport__refer__278EDA44”中的引用列列表匹配的主键或候选键。
解决方案
推荐阅读
- javascript - Mendeley API 文件下载失败
- apache-spark - Databricks 表/模式部署
- html - 在 HTML/CSS 中附加一个小方块的大方块
- amazon-web-services - 如何承担 Cognito 的跨账户角色?
- sql - Databricks - 通过 sql 命令进行字符串操作
- reporting-services - SSRS(Sequel Server Reporting Services)子报表返回“错误:无法显示子报表。”
- python - 如何从 csv 文件中逐年绘制数据?
- spring-boot - 如何从 Keycloak Integration Spring Boot 向 APM 发送自定义请求或响应标头
- python - itertools.tee 没有复制 groupby 迭代器
- r - 如何在R中更改绘图的比例