时间:2021-07-01 10:21:17 帮助过:3人阅读
1 CREATE TABLE zhujian ( 2 id int(11) PRIMARY KEY auto_increment, 3 name varchar(32) default ‘‘);
1 CREATE TABLE waijian ( 2 id int(11) PRIMARY KEY auto_increment, 3 zhujian_id int(11) default NULL, 4 name varchar(32) default ‘‘, 5 FOREIGN KEY (zhujian_id) REFERENCES zhujian (id));
1 insert into zhujian (name) values ("xiaostudy");
1 insert into waijian (zhujian_id, name) values (1, "smallstudy");
1 delete from zhujian where id=1;
1 delete from waijian where id=1;
1 alter table waijian add foreign key(zhujian_id) references zhujian(id) on delete cascade on update cascade;
mysql外键
标签:font for key bubuko bsp _id incr alt 增加