编辑代码

CREATE DATABASE test;
use test;
CREATE TABLE student (
	id int auto_increment primary key,
	name varchar(255),
	no varchar(255)
);

INSERT INTO student VALUES (null, '张三', '2000100101'),(null, '李四', '2000100102'),(null, '王五', '2000100103'),(null, '小二', '2000100104');


CREATE TABLE course (
	id int auto_increment primary key,
	name varchar(255)
);
INSERT INTO course VALUES(null,'java'),(null,'php'),(null,'mysql'),(null,'hadoop');
CREATE TABLE student_course (
    id int auto_increment primary key,
    studentid int not null ,
    courseid int not null ,
    constraint fk_courseid foreign key (courseid) references course (id),
    constraint fk_studentid foreign key (studentid) references student(id)
);
INSERT into student_course VALUES(null,1,1),(null,1,2),(null,1,3),(null,2,2),(null,2,3),(null,3,4);

SELECT * FROM student;
SELECT * FROM course;
SELECT * FROM student_course;