【发布时间】:2021-11-23 06:59:06
【问题描述】:
我正在尝试创建外键:
create table visit
(Num_vst int primary key,
date_vst date,
num_agnt int,
code_type int,
Constraint fk_vst foreign key (num_agnt,code_type)
references agente,type_de_verification (num_agnt,code_type);
问题出在哪里?
【问题讨论】:
-
您似乎在相关表的名称中有错字:
agente,type_de_verification。这应该是一个表名。也许那个逗号应该是一个点。 -
@TheImpaler 有 2 张桌子!比如 numa_agnt 与 agente 相关,而 code_type 与 type_de_verification 相关!与 2 个表相关的外键!我错了吗?
-
外键只能引用一张表,而且必须是完整的键。
标签: sql sql-server key