设为首页 加入收藏

TOP

mysql流程函数存储引擎InnoDB简单特性(三)
2015-07-24 11:32:16 来源: 作者: 【 】 浏览:6
Tags:mysql 流程 函数 存储 引擎 InnoDB 简单 特性
uery OK, 0 rows affected (0.05 sec) 插入记录: mysql> insert into country(country) values('china'); Query OK, 1 row affected (0.03 sec) mysql> select * from country; +------------+---------+ | country_id | country | +------------+---------+ | 1 | china | +------------+---------+ 1 row in set (0.00 sec) mysql> insert into city(country_id) values(1); Query OK, 1 row affected (0.11 sec) mysql> select * from city; +---------+------------+ | city_id | country_id | +---------+------------+ | 1 | 1 | +---------+------------+ 1 row in set (0.00 sec) city表依赖country表的country_id字段,删除会出错: mysql> delete from country where country_id=1; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constrai nt fails (`tom1/city`, CONSTRAINT `city_ibfk_1` FOREIGN KEY (`country_id`) REFER ENCES `country` (`country_id`) ON UPDATE CASCADE) 现在更新country表中的country_id字段,city表的country_id字段也会被同步更新,这是因为在创建city表的最后加了:on update cascade,即:更新时做级联操作 mysql> update country set country_id=1000 where country_id=1; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from city; +---------+------------+ | city_id | country_id | +---------+------------+ | 1 | 1000 | +---------+------------+ 1 row in set (0.00 sec)
首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇mysql多日志表结果集合拼接存储过.. 下一篇MySQL慢查询日志(SlowQueryLog)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·nginx 监听一个端口 (2025-12-25 00:19:30)
·整个互联网就没有一 (2025-12-25 00:19:27)
·囧次元最新官网入口 (2025-12-25 00:19:24)
·如何利用Python做数 (2025-12-24 23:48:36)
·如何使用python进行 (2025-12-24 23:48:34)