写出学生表,课程表,选课表的增,删,查,改的sql语句
时间: 2024-05-27 09:09:38 浏览: 73
1. 学生表的增、删、查、改的SQL语句:
- 增加学生:`INSERT INTO students (id, name, age, gender) VALUES ('001', '小明', 18, '男');`
- 删除学生:`DELETE FROM students WHERE id = '001';`
- 查询学生:`SELECT * FROM students WHERE id = '001';`
- 修改学生信息:`UPDATE students SET name = '小红', age = 19 WHERE id = '001';`
2. 课程表的增、删、查、改的SQL语句:
- 增加课程:`INSERT INTO courses (id, name, teacher) VALUES ('001', '数学', '张老师');`
- 删除课程:`DELETE FROM courses WHERE id = '001';`
- 查询课程:`SELECT * FROM courses WHERE id = '001';`
- 修改课程信息:`UPDATE courses SET name = '英语', teacher = '李老师' WHERE id = '001';`
3. 选课表的增、删、查、改的SQL语句:
- 增加选课记录:`INSERT INTO course_selection (student_id, course_id) VALUES ('001', '001');`
- 删除选课记录:`DELETE FROM course_selection WHERE student_id = '001' AND course_id = '001';`
- 查询选课记录:`SELECT * FROM course_selection WHERE student_id = '001';`
- 修改选课记录:`UPDATE course_selection SET course_id = '002' WHERE student_id = '001' AND course_id = '001';`
阅读全文