用sql语句将适量数据分别插入student、course,xuanke三张表中
时间: 2024-03-16 12:41:49 浏览: 79
假设student表中包含id、name、age、gender四列,course表中包含id、name、teacher、credit四列,xuanke表中包含id、student_id、course_id三列,且三个表的id列都为自增长主键。
插入student表数据的SQL语句如下:
```
INSERT INTO student (name, age, gender) VALUES ('张三', 20, '男');
INSERT INTO student (name, age, gender) VALUES ('李四', 22, '女');
INSERT INTO student (name, age, gender) VALUES ('王五', 19, '男');
```
插入course表数据的SQL语句如下:
```
INSERT INTO course (name, teacher, credit) VALUES ('数据库原理', '张老师', 3);
INSERT INTO course (name, teacher, credit) VALUES ('Java程序设计', '李老师', 4);
INSERT INTO course (name, teacher, credit) VALUES ('算法与数据结构', '王老师', 3);
```
插入xuanke表数据的SQL语句如下:
```
INSERT INTO xuanke (student_id, course_id) VALUES (1, 2);
INSERT INTO xuanke (student_id, course_id) VALUES (1, 3);
INSERT INTO xuanke (student_id, course_id) VALUES (2, 1);
INSERT INTO xuanke (student_id, course_id) VALUES (3, 3);
```
阅读全文