mysql> create table country(
> country_id smallint unsigned not null auto_increment,
>country varchar(50) not null,
>last_update timestamp not null default current_timestamp on update current_timestamp,
>primary key (country_id)
>)engine=InnoDB default charset = utf8;
mysql> ccreate 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 current_timestamp,
>primary key (city_id),
>key idx_fk_country_id (country_id),
>foreign key (country_id) references country (country_id)
>) ENGINE = InnoDB default charset=utf8;
时间: 2024-10-14 03:08:03