当前位置: 代码迷 >> Sql Server >> access数据库怎么级联更新、级联删除
  详细解决方案

access数据库怎么级联更新、级联删除

热度:3   发布时间:2016-04-27 17:48:56.0
access数据库如何级联更新、级联删除
我先是建立了一个表qjjbxx

create   table   qjjbxx(glbh   String   primary   key,ggrq   date)

然后又建立了一个表qjlx

create   table   qjlx(glbh   String,constraint   FK_glbh   foreign   key(glbh)   references   qjjbxx(glbh)   on   update   cascade   on   delete   cascade)

在运行第二个create时,提示我“constraint语句定义错误”,并在update处提示错误

请教各位这是出了什么问题?


------解决方案--------------------
create table a1(produce varchar(10) primary key)
insert into a1 select 'A '
insert into a1 select 'B '
insert into a1 select 'C '
insert into a1 select 'D '
insert into a1 select 'E '

create table a2(produce varchar(10) not null
foreign key references a1(produce) on delete cascade
on update cascade--建表时就这样定义(更新与删除)
,val int)
insert into a2 select 'A ',1
insert into a2 select 'B ',2
insert into a2 select 'C ',3
insert into a2 select 'D ',4
insert into a2 select 'E ',5

alter table a2 add constraint a2_con foreign key(produce)references a1(produce) on delete cascade on update cascade
  相关解决方案