MySQL数据库外键的相关知识详解

复制Create table country( country_id smallint unsigned not null auto_increment,数识详 country varchar(50) not null, last_update timestamp not null, primary key(country_id) )engine=innoDB default charset=utf8; Create table city( city_id smallint unsigned not null auto_increment, city varchar(50) not null, country_id smallint unsigned not null, last_update timestamp not null default current_timestamp on update curren_timestamp, Primary key(city_id), key idx_fk_country_id (country_id), constraint fk_city_country Foreign Key(country_id) References country(country_id) on DELETE restrict ON update cascade )engine=innoDB default charset=utf8; 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.