alter table exam_definition modify lesson_id bigint null comment '所属课程ID', add map_id bigint not null comment '地图id' after id; -- 更新exam_definition的map_id字段 UPDATE exam_definition SET map_id =( SELECT map_id FROM ls_lesson WHERE exam_definition.lesson_id = ls_lesson.id); -- 更新exam_definition的type字段 UPDATE exam_definition SET type =( SELECT prd_type FROM ls_lesson WHERE exam_definition.lesson_id = ls_lesson.id); alter table org_exam modify org_id bigint not null, add creator_id bigint not null, add create_time datetime not null; ALTER TABLE `org_exam` ADD COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY (`id`); -- org_lesson表添加主键 ALTER TABLE `org_lesson` ADD COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY (`id`);