Pull to refresh
32
0
svetasmirnova @svetasmirnova

User

Send message
Вопрос теперь понятен :)
А что имеется в виду под каскадным удалением внутри одной таблицы?

Что-то типа этого:

mysql> drop table t3;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE `t3` ( `i3` int(11) not null primary key, `j3` int(11) not null, foreign key(j3) references t3(i3) on delete cascade) engine=innodb;
Query OK, 0 rows affected (0.11 sec)

mysql> insert into t3 values(1,1),(2,2),(3,3),(4,1);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0

mysql> select * from t3;
+----+----+
| i3 | j3 |
+----+----+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 1 |
+----+----+
4 rows in set (0.00 sec)

mysql> delete from t3 where i3=1;
Query OK, 1 row affected (0.00 sec)

mysql> select * from t3;
+----+----+
| i3 | j3 |
+----+----+
| 2 | 2 |
| 3 | 3 |
+----+----+
2 rows in set (0.00 sec)
12 ...
18

Information

Rating
Does not participate
Date of birth
Registered
Activity