Composite foreign key (FOREIGN KEY) a combination of multi-column primary key (PRIMARY KEY)

A table, its foreign key reference that is a primary key of another table, but the association is a key combination, the two or more columns.

You can take a look at this " multi-column combination of the primary key (PRIMARY KEY) " https://www.cnblogs.com/insus/p/11068755.html


CREATE TABLE [dbo].[T4]
(
    [col_1] NVARCHAR(10) NOT NULL,
    [col_2] NVARCHAR(10) NOT NULL,
    [col_3] NVARCHAR(10) NULL,
    [col_4] NVARCHAR(10) NULL
)
GO

ALTER TABLE [dbo].[T4]
   ADD CONSTRAINT [FK__T4__0000000000000004]
   FOREIGN KEY([col_1],[col_2])
   REFERENCES [dbo].[T3]([col1],[col2])
GO
Source Code

 

 

Guess you like

Origin www.cnblogs.com/insus/p/11068796.html