| 1 |
create table parent ( |
| 2 |
a int primary key, |
| 3 |
b int not null, |
| 4 |
c int not null, |
| 5 |
unique(b) using hash, |
| 6 |
index(c)) engine = ndb; |
| 7 |
create table child ( |
| 8 |
a int primary key, |
| 9 |
b int not null, |
| 10 |
c int not null, |
| 11 |
unique(b) using hash, |
| 12 |
index(c)) engine = ndb; |
| 13 |
insert into parent values (1,2,3); |
| 14 |
insert into child values (3,4,5); |
| 15 |
alter table child algorithm=inplace, add constraint fkname foreign key (a) references parent(a); |
| 16 |
ERROR HY000: Cannot add foreign key constraint |
| 17 |
show warnings; |
| 18 |
Level Code Message |
| 19 |
Warning 1296 Got error 21033 'Create foreign key failed in NDB - No parent row found' from NDB |
| 20 |
Error 1215 Cannot add foreign key constraint |
| 21 |
alter table child algorithm=inplace, add constraint fkname foreign key(b) references parent(a); |
| 22 |
ERROR HY000: Cannot add foreign key constraint |
| 23 |
show warnings; |
| 24 |
Level Code Message |
| 25 |
Warning 1296 Got error 21033 'Create foreign key failed in NDB - No parent row found' from NDB |
| 26 |
Error 1215 Cannot add foreign key constraint |
| 27 |
alter table child algorithm=inplace, add constraint fkname foreign key(c) references parent(a); |
| 28 |
ERROR HY000: Cannot add foreign key constraint |
| 29 |
show warnings; |
| 30 |
Level Code Message |
| 31 |
Warning 1296 Got error 21033 'Create foreign key failed in NDB - No parent row found' from NDB |
| 32 |
Error 1215 Cannot add foreign key constraint |
| 33 |
alter table child algorithm=inplace, add constraint fkname foreign key(a) references parent(b); |
| 34 |
ERROR HY000: Cannot add foreign key constraint |
| 35 |
show warnings; |
| 36 |
Level Code Message |
| 37 |
Warning 1296 Got error 21033 'Create foreign key failed in NDB - No parent row found' from NDB |
| 38 |
Error 1215 Cannot add foreign key constraint |
| 39 |
alter table child algorithm=inplace, add constraint fkname foreign key(b) references parent(b); |
| 40 |
ERROR HY000: Cannot add foreign key constraint |
| 41 |
show warnings; |
| 42 |
Level Code Message |
| 43 |
Warning 1296 Got error 21033 'Create foreign key failed in NDB - No parent row found' from NDB |
| 44 |
Error 1215 Cannot add foreign key constraint |
| 45 |
alter table child algorithm=inplace, add constraint fkname foreign key(c) references parent(b); |
| 46 |
ERROR HY000: Cannot add foreign key constraint |
| 47 |
show warnings; |
| 48 |
Level Code Message |
| 49 |
Warning 1296 Got error 21033 'Create foreign key failed in NDB - No parent row found' from NDB |
| 50 |
Error 1215 Cannot add foreign key constraint |
| 51 |
insert into parent values (2,3,4); |
| 52 |
insert into parent values (3,4,5); |
| 53 |
insert into parent values (4,5,6); |
| 54 |
insert into parent values (5,6,7); |
| 55 |
alter table child algorithm=inplace, add constraint fk1 foreign key(a) references parent(a); |
| 56 |
alter table child algorithm=inplace, add constraint fk2 foreign key(b) references parent(a); |
| 57 |
alter table child algorithm=inplace, add constraint fk3 foreign key(c) references parent(a); |
| 58 |
alter table child algorithm=inplace, add constraint fk4 foreign key(a) references parent(b); |
| 59 |
alter table child algorithm=inplace, add constraint fk5 foreign key(b) references parent(b); |
| 60 |
alter table child algorithm=inplace, add constraint fk6 foreign key(c) references parent(b); |
| 61 |
alter table child algorithm=inplace, |
| 62 |
drop foreign key fk1, |
| 63 |
drop foreign key fk2, |
| 64 |
drop foreign key fk3, |
| 65 |
drop foreign key fk4, |
| 66 |
drop foreign key fk5, |
| 67 |
drop foreign key fk6; |
| 68 |
drop table parent, child; |
| 69 |
create table parent ( |
| 70 |
b1 int as (b) stored not null, |
| 71 |
c1 int as (c) stored not null, |
| 72 |
a1 int as (a) stored not null, |
| 73 |
b2 int as (b) stored not null, |
| 74 |
c2 int as (c) stored not null, |
| 75 |
a2 int as (a) stored not null, |
| 76 |
a int default 0, |
| 77 |
b int default 0, |
| 78 |
c int default 0, |
| 79 |
primary key pk1 (a1,b1,c1) using hash, |
| 80 |
unique key uk2 (a2,b2,c2) using hash |
| 81 |
) engine=ndbcluster; |
| 82 |
create table child ( |
| 83 |
a int default 0, |
| 84 |
b int default 0, |
| 85 |
c int default 0, |
| 86 |
d int default 0, |
| 87 |
e int default 0, |
| 88 |
f int default 0, |
| 89 |
b1 int as (b) stored not null, |
| 90 |
c1 int as (c) stored not null, |
| 91 |
a1 int as (a) stored not null, |
| 92 |
b2 int as (b) stored not null, |
| 93 |
c2 int as (c) stored not null, |
| 94 |
a2 int as (a) stored not null, |
| 95 |
b3 int as (b) stored not null, |
| 96 |
c3 int as (c) stored not null, |
| 97 |
a3 int as (a) stored not null, |
| 98 |
primary key pk1 (a1,b1,c1) using hash, |
| 99 |
unique key uk2 (a2,b2,c2) using hash, |
| 100 |
key ok3 (a3,b3,c3), |
| 101 |
key ok3def (c3,b3,a3,d,e,f) |
| 102 |
) engine=ndbcluster; |
| 103 |
insert into parent (a, b, c) values (11, 12, 13); |
| 104 |
insert into child (a, b, c) values (11, 12, 13); |
| 105 |
alter table child add |
| 106 |
constraint fk11 foreign key (c1,b1,a1) references parent (c1,b1,a1); |
| 107 |
alter table child add |
| 108 |
constraint fk21 foreign key (c2,b2,a2) references parent (c1,b1,a1); |
| 109 |
alter table child add |
| 110 |
constraint fk31 foreign key (c3,b3,a3) references parent (c1,b1,a1); |
| 111 |
alter table child add |
| 112 |
constraint fk12 foreign key (c1,b1,a1) references parent (c2,b2,a2); |
| 113 |
alter table child add |
| 114 |
constraint fk22 foreign key (c2,b2,a2) references parent (c2,b2,a2); |
| 115 |
alter table child add |
| 116 |
constraint fk32 foreign key (c3,b3,a3) references parent (c2,b2,a2); |
| 117 |
drop table child, parent; |