外键
创建方式一(建表时)
drop table if EXISTS score;
CREATE TABLE `score` (
`scid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`sid` int(10) unsigned NOT NULL,
`cid` int(5) unsigned NOT NULL,
`score` float(5,2) DEFAULT NULL,
PRIMARY KEY (`scid`),
foreign key(sid) references student(sid)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8
创建方式二(建表后)
alter table score add FOREIGN key(sid) REFERENCES student(sid);