学数据库中
create table Staff(
staffNO char(5) not null unique,
name varchar(30) not null,
position varchar(10) not null,
salary money not null,
branchNO char(4) not null,
constraint pk1 primary key(staffNO)
)
create table Branch(
branchNO char(4) not null unique,
street varchar(60) not null,
city varchar(20) not null,
state char(2) not null,
zipCode char(5) not null,
mgrStaffNO char(5) not null,
constraint pk2 primary key(branchNO),
constraint fk1 foreign key(mgrStaffNO) references Staff
on update cascade on delete no action
)
建了这两张表后,我想添加约束
alter table Staff
add constraint fk2 foreign key(branchNO)references Branch on update cascade on delete no action
添加不了。
不知道怎么用on update cascade on delete no action高手帮忙回答下啊!
create table Staff(
staffNO char(5) not null unique,
name varchar(30) not null,
position varchar(10) not null,
salary money not null,
branchNO char(4) not null,
constraint pk1 primary key(staffNO)
)
create table Branch(
branchNO char(4) not null unique,
street varchar(60) not null,
city varchar(20) not null,
state char(2) not null,
zipCode char(5) not null,
mgrStaffNO char(5) not null,
constraint pk2 primary key(branchNO),
constraint fk1 foreign key(mgrStaffNO) references Staff
on update cascade on delete no action
)
建了这两张表后,我想添加约束
alter table Staff
add constraint fk2 foreign key(branchNO)references Branch on update cascade on delete no action
添加不了。
不知道怎么用on update cascade on delete no action高手帮忙回答下啊!
ADD CONSTRAINT FK_branchNO FOREIGN KEY(branchNO) REFERENCES Branch(branchNO)
ON UPDATE CASCADE
ON DELETE NO ACTION
ADD CONSTRAINT FK_branchNO FOREIGN KEY(branchNO) REFERENCES Branch(branchNO)
ON UPDATE CASCADE
--ON DELETE NO ACTION 可以去掉默认选项