guoyu/log/Sql/fix_learning_detail_add_courseware_id.sql

24 lines
706 B
MySQL
Raw Normal View History

-- 修复 learning_detail 表:添加 courseware_id 字段
-- 执行日期2025-12-05
USE ry_study;
-- 1. 添加 courseware_id 字段
ALTER TABLE learning_detail
ADD COLUMN `courseware_id` bigint DEFAULT NULL COMMENT '课件ID'
AFTER `course_id`;
-- 2. 添加索引以提高查询性能
ALTER TABLE learning_detail
ADD INDEX `idx_courseware_id` (`courseware_id`);
-- 3. 添加联合索引(用于查询某个学生的某个课程的所有课件学习详情)
ALTER TABLE learning_detail
ADD INDEX `idx_student_course_courseware` (`student_id`, `course_id`, `courseware_id`);
-- 4. 验证字段是否添加成功
DESC learning_detail;
-- 5. 查看表结构
SHOW CREATE TABLE learning_detail;