编辑代码

CREATE DATABASE mytest;
use mytest;
CREATE TABLE Student (
	id int primary key auto_increment,
	name varchar(255),
	address varchar(255),
	city varchar(255)
);
CREATE TABLE Course(
    sno int(5) not null,
    cno int(5) not null,
    degree int(3) null,
    primary key(sno,cno)
);
INSERT into Course VALUES(1,1,30);
INSERT into Course VALUES(2,1,50);
INSERT into Course VALUES(2,2,50);
INSERT into Course VALUES(3,1,80);
INSERT into Course VALUES(4,2,10);

INSERT INTO Student VALUES (0, '张三', '李四家隔壁', '杭州');
INSERT INTO Student VALUES (0, '李四',  '张三家隔壁', '北京');
INSERT INTO Student VALUES(0,'王五','山东','北京');
INSERT INTO Student VALUES(0,'赵六','山东','北京');


select name,cno,degree from Student,Course where Student.id = Course.sno;
update Course set degree=100
where Course.sno=1;
select name,cno,degree from Student,Course where Student.id = Course.sno;
INSERT into Course VALUES(3,2,20);
select name,cno,degree from Student,Course where Student.id = Course.sno;
delete from Course where Course.sno=3 and Course.cno=2;
select name,cno,degree from Student,Course where Student.id = Course.sno;