mysql> select version();
Код:
+--------------+
| version() |
+--------------+
| 5.0.13-rc-nt |
+--------------+
1 row in set (0.00 sec)
mysql> show variables like 'storage_engine';
Код:
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
1 row in set (0.00 sec)
mysql> use test;
Database changed
mysql> create table a (aid int not null auto_increment primary key, atext varchar(255));
Query OK, 0 rows affected (0.42 sec)
mysql> create table b (bid int not null auto_increment primary key, aid int not null, btext varchar(255), foreign key fk_aid (aid) references a (aid) on delete cascade);
Query OK, 0 rows affected (0.53 sec)
mysql> insert into a (atext) values ('a1'), ('a2');
Query OK, 2 rows affected (0.53 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into b (aid, btext) value (1, 'b1'), (2, 'b2');
Query OK, 2 rows affected (0.08 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> delete from a where aid=1;
Query OK, 1 row affected (0.17 sec)
mysql> select * from b;
Код:
+-----+-----+-------+
| bid | aid | btext |
+-----+-----+-------+
| 2 | 2 | b2 |
+-----+-----+-------+
1 row in set (0.00 sec)
mysql>