-- 学生表 CREATE TABLE Students( s_id VARCHAR(20), s_name VARCHAR(20) NOT NULL, s_birth VARCHAR(20) NOT NULL , s_sex VARCHAR(10) NOT NULL , PRIMARY KEY(s_id) ); select * from Students; -- 课程表 CREATE TABLE Courses( c_id VARCHAR(20), c_name VARCHAR(20) NOT NULL , t_id VARCHAR(20) NOT NULL, PRIMARY KEY(c_id) ); -- 教师表 CREATE TABLE Teachers( t_id VARCHAR(20), t_name VARCHAR(20) NOT NULL, PRIMARY KEY(t_id) ); -- 成绩表 CREATE TABLE Scores( s_id VARCHAR(20), c_id VARCHAR(20), s_score number(3), PRIMARY KEY(s_id,c_id) ); -- 插入学生表测试数据 INSERT INTO Students VALUES('01' , '赵雷' , '1990-01-01' , '男'); INSERT INTO Students VALUES('02' , '钱电' , '1990-12-21' , '男'); INSERT INTO Students VALUES('03' , '孙风' , '1990-05-20' , '男'); INSERT INTO Students VALUES('04' , '李云' , '1990-08-06' , '男'); INSERT INTO Students VALUES('05' , '周梅' , '1991-12-01' , '女'); INSERT INTO Students VALUES('06' , '吴兰' , '1992-03-01' , '女'); INSERT INTO Students VALUES('07' , '郑竹' , '1989-07-01' , '女'); INSERT INTO Students VALUES('08' , '王菊' , '1990-01-20' , '女'); -- 课程表测试数据 INSERT INTO Courses VALUES('01' , '语文' , '02'); INSERT INTO Courses VALUES('02' , '数学' , '01'); INSERT INTO Courses VALUES('03' , '英语' , '03'); COMMIT ; -- 教师表测试数据 INSERT INTO Teachers VALUES('01' , '张三'); INSERT INTO Teachers VALUES('02' , '李四'); INSERT INTO Teachers VALUES('03' , '王五'); -- 成绩表测试数据 INSERT INTO Scores VALUES('01' , '01' , 80); INSERT INTO Scores VALUES('01' , '02' , 90); INSERT INTO Scores VALUES('01' , '03' , 99); INSERT INTO Scores VALUES('02' , '01' , 70); INSERT INTO Scores VALUES('02' , '02' , 60); INSERT INTO Scores VALUES('02' , '03' , 80); INSERT INTO Scores VALUES('03' , '01' , 80); INSERT INTO Scores VALUES('03' , '02' , 80); INSERT INTO Scores VALUES('03' , '03' , 80); INSERT INTO Scores VALUES('04' , '01' , 50); INSERT INTO Scores VALUES('04' , '02' , 30); INSERT INTO Scores VALUES('04' , '03' , 20); INSERT INTO Scores VALUES('05' , '01' , 76); INSERT INTO Scores VALUES('05' ,
50道SQL经典例题(oracle)
最新推荐文章于 2024-07-18 15:32:08 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)