Habr
β
How to become an author
My feed
All streams
Development
Admin
Design
Management
Marketing
PopSci
Search
Write a publication
Settings
Login
Pull to refresh
32
0
svetasmirnova
@svetasmirnova
User
Follow
Send message
Profile
Publications
5
Comments
342
Bookmarks
125
More
Dropdown
Followers
20
Following
3
Copy RSS link
Вопросы авторам MySQL на PHPConf 2008 29-30мая в Москве
svetasmirnova
May 1 2008 at 09:56
Вопрос теперь понятен :)
Вопросы авторам MySQL на PHPConf 2008 29-30мая в Москве
svetasmirnova
Apr 30 2008 at 11:58
А что имеется в виду под каскадным удалением внутри одной таблицы?
Что-то типа этого:
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)
Back
Here
1
2
...
16
17
18
There
Back
Information
Rating
Does not participate
Date of birth
October 17 1976
Registered
April 30 2008
Activity
October 6 2023 at 16:22
Что-то типа этого:
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)