我的过程如下:
--建立主表:
CREATE TABLE `country` (
  `country_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `country` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`country_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1--建立从表CREATE table city
(
city_id int not null auto_increment,
city varchar(20),
country_id int,
primary key(city_id)
) engine = InnoDB;--给外键列加索引
alter table city add index idx_s(country_id);--加外键约束  ---这部出错了
alter table city add constraint fk_city_country 
foreign key(country_id)
references country(country_id);
弄了半天 感觉语法没错 。求指教