1.创建表a
create table a(
name char(20) not null,
id char(20) not null primary key);
2.创建表b
create table b(
b_name char(20) not null,
b_id char(20) not null ,
constraint foreign key(b_id) references a(id) on delete cascade);
开发语言:java,支持数据库:Mysql 5,系统架构:J2EE,操作系统:linux/Windows1. 引言 32. 系统的结构 32.1 系统概述 33. 功能模块设计说明 43.1 商品管理 43.1.1 添加商品功能模块 53.1.2 商品列表功能模块 83.1.3 商品关联功能模块 93.
0
3.表建好后,插入数据
insert into a values("111","1");
insert into a values("222","2");
在b表中插入下面数据 insert into b values("1","1"); 显示插入成功。
在b表中插入下面数据 insert into b values("1","3"); 显示插入失败。是因为这里设置了外键而a表中的id没(id=="3")的数据。
执行delete from a where id="1"; b表中的数据也会被删除掉。这里就应用到了级联删除。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号