一、添加主外键约束:
1、生成表时(添加字段的注释):
CREATE TABLE `student`
`id` varchar(64) COLLATE utf8_bin NOT NULL COMMENT '编号',
`qs_id` varchar(64) COLLATE utf8_bin NOT NULL COMMENT '问题统计编号',
`question` varchar(512) COLLATE utf8_bin NOT NULL COMMENT '问题',
PRIMARY KEY (`id`),
KEY `fk_1` (`qs_id`),
CONSTRAINT `fk_1` FOREIGN KEY (`qs_id`) REFERENCES `question_statistics_data` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='问题词性数据';
2、修改表时添加:
ALTER TABLE `question_model_library` ADD CONSTRAINT `fk_2` FOREIGN KEY (`qs_id`) REFERENCES `question_statistics_data` (`id`);
二、修改数据库、表的字符集:
ALTER DATABASE training_data DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE training_data DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;