小弟求救,级联删除不起作用????
时间:2008-07-25
来源:互联网
我的语句如下,所照着手册写的,但是级联删除不起作用,在线等高人搭救,谢谢.....
CREATE TABLE `jos_sf_magzine` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL DEFAULT '',
`publishdate` DATE NULL ,
`introtext` text NOT NULL DEFAULT '',
`toc` text NOT NULL DEFAULT '',
`cover` varchar(100) NULL ,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
CREATE TABLE `jos_sf_magzine_article` (
`aid` int(11) NOT NULL auto_increment,
`magzineid` int(11) NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`aid`),
INDEX (`magzineid`),
FOREIGN KEY (`magzineid`) REFERENCES jos_sf_magzine(`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
CREATE TABLE `jos_sf_magzine` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL DEFAULT '',
`publishdate` DATE NULL ,
`introtext` text NOT NULL DEFAULT '',
`toc` text NOT NULL DEFAULT '',
`cover` varchar(100) NULL ,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
CREATE TABLE `jos_sf_magzine_article` (
`aid` int(11) NOT NULL auto_increment,
`magzineid` int(11) NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`aid`),
INDEX (`magzineid`),
FOREIGN KEY (`magzineid`) REFERENCES jos_sf_magzine(`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
作者: qianjin03 发布时间: 2008-07-24
mysql> CREATE TABLE `jos_sf_magzine` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL DEFAULT '',
`publishdate` DATE NULL ,
`introtext` text NOT NULL DEFAULT '',
`toc` text NOT NULL DEFAULT '',
`cover` varchar(100) NULL ,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected
mysql> CREATE TABLE `jos_sf_magzine_article` (
`aid` int(11) NOT NULL auto_increment,
`magzineid` int(11) NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`aid`),
INDEX (`magzineid`),
FOREIGN KEY (`magzineid`) REFERENCES jos_sf_magzine(`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected
mysql> select * from jos_sf_magzine;
+----+------+-------------+-----------+-----+-------+---------------------+
| id | name | publishdate | introtext | toc | cover | created |
+----+------+-------------+-----------+-----+-------+---------------------+
| 1 | | NULL | | | NULL | 0000-00-00 00:00:00 |
| 2 | | NULL | | | NULL | 0000-00-00 00:00:00 |
| 3 | | NULL | | | NULL | 0000-00-00 00:00:00 |
+----+------+-------------+-----------+-----+-------+---------------------+
3 rows in set
mysql> select * from jos_sf_magzine_article;
+-----+-----------+-------+---------+---------------------+
| aid | magzineid | title | content | created |
+-----+-----------+-------+---------+---------------------+
| 1 | 1 | | | 0000-00-00 00:00:00 |
| 2 | 1 | | | 0000-00-00 00:00:00 |
| 3 | 2 | | | 0000-00-00 00:00:00 |
| 4 | 2 | | | 0000-00-00 00:00:00 |
+-----+-----------+-------+---------+---------------------+
4 rows in set
mysql> delete from jos_sf_magzine where id = '1';
Query OK, 1 row affected
mysql> select * from jos_sf_magzine_article;
+-----+-----------+-------+---------+---------------------+
| aid | magzineid | title | content | created |
+-----+-----------+-------+---------+---------------------+
| 3 | 2 | | | 0000-00-00 00:00:00 |
| 4 | 2 | | | 0000-00-00 00:00:00 |
+-----+-----------+-------+---------+---------------------+
2 rows in set
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL DEFAULT '',
`publishdate` DATE NULL ,
`introtext` text NOT NULL DEFAULT '',
`toc` text NOT NULL DEFAULT '',
`cover` varchar(100) NULL ,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected
mysql> CREATE TABLE `jos_sf_magzine_article` (
`aid` int(11) NOT NULL auto_increment,
`magzineid` int(11) NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`aid`),
INDEX (`magzineid`),
FOREIGN KEY (`magzineid`) REFERENCES jos_sf_magzine(`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected
mysql> select * from jos_sf_magzine;
+----+------+-------------+-----------+-----+-------+---------------------+
| id | name | publishdate | introtext | toc | cover | created |
+----+------+-------------+-----------+-----+-------+---------------------+
| 1 | | NULL | | | NULL | 0000-00-00 00:00:00 |
| 2 | | NULL | | | NULL | 0000-00-00 00:00:00 |
| 3 | | NULL | | | NULL | 0000-00-00 00:00:00 |
+----+------+-------------+-----------+-----+-------+---------------------+
3 rows in set
mysql> select * from jos_sf_magzine_article;
+-----+-----------+-------+---------+---------------------+
| aid | magzineid | title | content | created |
+-----+-----------+-------+---------+---------------------+
| 1 | 1 | | | 0000-00-00 00:00:00 |
| 2 | 1 | | | 0000-00-00 00:00:00 |
| 3 | 2 | | | 0000-00-00 00:00:00 |
| 4 | 2 | | | 0000-00-00 00:00:00 |
+-----+-----------+-------+---------+---------------------+
4 rows in set
mysql> delete from jos_sf_magzine where id = '1';
Query OK, 1 row affected
mysql> select * from jos_sf_magzine_article;
+-----+-----------+-------+---------+---------------------+
| aid | magzineid | title | content | created |
+-----+-----------+-------+---------+---------------------+
| 3 | 2 | | | 0000-00-00 00:00:00 |
| 4 | 2 | | | 0000-00-00 00:00:00 |
+-----+-----------+-------+---------+---------------------+
2 rows in set
作者: devotedsky 发布时间: 2008-08-01
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28