469,110 Members | 1,986 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,110 developers. It's quick & easy.

foreign key - on update cascade

Hi, I'm using:

- Red Hat 9
- MySQL 3.23.56
create table t1(
id integer not null,
primary key(id)) type = INNODB;

create table t2(
id integer not null,
code char(5) not null,
primary key(id,code)) type = INNODB;

create index t2_id on t2(id);
alter table t2 add constraint foreign key (id) references t1 (id) ON

insert into t1(id) values(1);
insert into t2(id,code) values(1,'a');
insert into t2(id,code) values(1,'b');
update t1 set id=2 where id=1;
I get the following error message:
"ERROR 1217: Cannot delete a parent row: a foreign key constraint
What am I doing wrong?

Jul 19 '05 #1
0 3574

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jeremiah Jacks | last post: by
reply views Thread by Rainer Collet | last post: by
2 posts views Thread by Gunnar Vřyenli | last post: by
reply views Thread by Rob Panosh | last post: by
11 posts views Thread by FreeToGolfAndSki | last post: by
5 posts views Thread by Bob Stearns | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.