Current Path : /home/usr.opt/mysql57/mysql-test/suite/ndb/r/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/ndb/r/ndb_fk_cascade_delete_multi.result |
create table emp ( id int primary key auto_increment, name varchar(256) not null, manager int, index(manager)) engine = ndb; alter table emp add constraint fkname foreign key (manager) references emp(id) on update restrict on delete cascade; insert into emp values (1, 'larry', null) ,(2, 'eddie', 1) ,(3, 'tomas', 2) ,(4, 'ricky', 2) ,(5, 'edwin', 2) ,(6, 'bockie', 3) ,(7, 'jonas', 6) ,(8, 'magnus', 6) ,(9, 'frasse', 6) ,(10, 'samuel', 7) ,(11, 'jonatan', 7) ,(12, 'wille', 8); select * from emp order by 1; id name manager 1 larry NULL 2 eddie 1 3 tomas 2 4 ricky 2 5 edwin 2 6 bockie 3 7 jonas 6 8 magnus 6 9 frasse 6 10 samuel 7 11 jonatan 7 12 wille 8 begin; delete from emp where id=6; select * from emp order by 1; id name manager 1 larry NULL 2 eddie 1 3 tomas 2 4 ricky 2 5 edwin 2 rollback; select * from emp order by 1; id name manager 1 larry NULL 2 eddie 1 3 tomas 2 4 ricky 2 5 edwin 2 6 bockie 3 7 jonas 6 8 magnus 6 9 frasse 6 10 samuel 7 11 jonatan 7 12 wille 8 alter table emp drop foreign key fkname; drop table emp; create table tree ( id int primary key, value varchar(256) not null, parent int null, left_child int null, right_child int null, index (parent), unique (left_child), unique (right_child)) engine = ndb; insert into tree values (0, '3-root', null, 1,2); insert into tree values (1, '1-inner', 0, 3,4); insert into tree values (2, '5-inner', 0, 5,6); insert into tree values (3, '0-leaf', 1, null, null); insert into tree values (4, '2-leaf', 1, null, null); insert into tree values (5, '4-leaf', 2, null, null); insert into tree values (6, '6-leaf', 2, null, null); select * from tree order by 1; id value parent left_child right_child 0 3-root NULL 1 2 1 1-inner 0 3 4 2 5-inner 0 5 6 3 0-leaf 1 NULL NULL 4 2-leaf 1 NULL NULL 5 4-leaf 2 NULL NULL 6 6-leaf 2 NULL NULL alter table tree add constraint fk_parent foreign key (parent) references tree(id) on update restrict on delete cascade; alter table tree add constraint fk_left foreign key (left_child) references tree(id) on update restrict on delete cascade; begin; delete from tree where value = '5-inner'; select * from tree order by 1; id value parent left_child right_child 0 3-root NULL 1 2 1 1-inner 0 3 4 3 0-leaf 1 NULL NULL 4 2-leaf 1 NULL NULL rollback; begin; delete from tree where value = '4-leaf'; select * from tree order by 1; id value parent left_child right_child 0 3-root NULL 1 2 1 1-inner 0 3 4 3 0-leaf 1 NULL NULL 4 2-leaf 1 NULL NULL rollback; begin; delete from tree where value = '3-root'; select * from tree order by 1; id value parent left_child right_child commit; drop table tree;