sqlserver 设置名称不一样的主外键关系 且通过走索引而不是主键不影响主表
A表
索引
/****** Object: Index [IX_Sec_JobPost_Code] Script Date: 2021-07-11 18:27:13 ******/
DROP INDEX [IX_Sec_JobPost_Code] ON [dbo].[Sec_JobPost]
GO
/****** Object: Index [IX_Sec_JobPost_Code] Script Date: 2021-07-11 18:27:13 ******/
CREATE UNIQUE NONCLUSTERED INDEX [IX_Sec_JobPost_Code] ON [dbo].[Sec_JobPost]
(
[Code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
GO
B表