SQL语句,表与表之间的引⽤constraint外键表名_id_fk foreign key (外键字段名) references主表名(主表id)
foreign key references用法
create table FirNav
(
id int primary key identity(1,1) not null,
navName varchar(10) not null,
);
create table SecNav
(
id int primary key identity(1,1) not null,
navName varchar(10) not null,
firId int ,
constraint SecNav_id_fk foreign key (firId) references FirNav(id)
);
create table ThirdNav
(
id int primary key identity(1,1) not null,
navName varchar(10) not null,
secId int,
constraint ThirdNav_id_fk foreign key (secId) references SecNav(id)
);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。