院校招录信息表COLLEGE
CREATE TABLE COLLEGE(
院校代码 NUMBER(8) PRIMARY KEY,
院校名称 VARCHAR2(30) NOT NULL,
录取分数线 NUMBER(3) CHECK(录取分数线 BETWEEN 300 AND 700),
招生人数 NUMBER(4) CHECK(招生人数 <= 10),
录取人数 NUMBER(4) DEFAULT 0
);
学生信息总表STUDENT
CREATE TABLE STUDENT(
准考证号 VARCHAR2(12) PRIMARY KEY,
姓名 VARCHAR2(8) NOT NULL,
性别 VARCHAR2(4) CHECK(性别 IN('1','2')),
×××号 VARCHAR2(18) NOT NULL,
省份 VARCHAR2(8) NOT NULL,
文理科 VARCHAR2(6) DEFAULT NULL CHECK(文理科 IN('1','2')),
总分 NUMBER(3) CHECK(总分<=700),
一志愿 NUMBER(4),
二志愿 NUMBER(4),
同意调剂 VARCHAR2(8) DEFAULT '0',
录取状态 VARCHAR2(8) DEFAULT '0',
录取志愿 VARCHAR2(8) DEFAULT NULL CHECK(录取志愿 IN('1','2', '3')),
录取院校 NUMBER(8) DEFAULT NULL,
录取日期 DATE,
操作人 VARCHAR2(8),
CONSTRAINT FK_1 FOREIGN KEY (一志愿) REFERENCES COLLEGE(院校代码),
CONSTRAINT FK_2 FOREIGN KEY (二志愿) REFERENCES COLLEGE(院校代码),
CONSTRAINT FK_3 FOREIGN KEY (录取院校) REFERENCES COLLEGE(院校代码)
);
创建序列STUNO_SQU
CREATE SEQUENCE STUNO_SQU
START WITH 201301420001
INCREMENT BY 1
NOCACHE
NOCYCLE;
考试成绩表TSCORE
CREATE TABLE TSCORE(
准考证号 VARCHAR2(12),
语文 NUMBER(3) CHECK(语文<=150),
数学 NUMBER(3) CHECK(数学<=150),
英语 NUMBER(3) CHECK(英语<=150),
综合 NUMBER(3) CHECK(综合<=300)
);
改分
UPDATE TSCORE SET 语文=553 WHERE 准考证号=10002;
COMMIT;
通过联合查询检查考生的志愿
SELECT 姓名,总分,院校名称 FROM student s,college c WHERE s.一志愿=c.院校代码;
创建视图
1. 考生成绩视图
CREATE VIEW 考生成绩(准考证号,姓名,总分)
AS SELECT 准考证号,姓名,总分 FROM student
WITH READ ONLY;
生成考生成绩视图的同义词score:
CREATE SYNONYM SCORE FOR 考生成绩;
2.录取考生视图
CREATE VIEW 录取考生(准考证号,姓名,录取院校名称)
AS SELECT 准考证号,姓名,院校名称 FROM student,college
WHERE 录取状态='1' AND student.录取院校=college.院校代码
WITH READ ONLY;
生成录取考生视图的同义词RESULT:
CREATE SYNONYM RESULT FOR 录取考生;
3.录取情况视图
CREATE VIEW 录取情况(院校代码,院校名称,状态,招生人数,缺额)
AS SELECT 院校代码,院校名称,DECODE(SIGN(招生人数-录取人数),1,'未完成','完成'),招生人数,招生人数-录取人数
FROM college WITH READ ONLY;
生成录取情况视图的同义词STATUS:
CREATE SYNONYM STATUS FOR 录取情况;
函数的创建
1. 返回考生姓名函数GET_STUDENT_NAME
CREATE OR REPLACE FUNCTION GET_STUDENT_NAME(P_ZKZH VARCHAR2)
RETURN VARCHAR2
AS
V_NAME VARCHAR2(10);
BEGIN
SELECT 姓名 INTO V_NAME FROM STUDENT WHERE 准考证号=P_ZKZH;
RETURN(V_NAME);
EXCEPTION
WHEN OTHERS THEN
RETURN('无');
END;
/
2. 返回考生成绩函数GET_SCORE
CREATE OR REPLACE FUNCTION GET_SCORE (P_ZKZH VARCHAR2)
RETURN VARCHAR2
AS
V_SCORE NUMBER(3);
BEGIN
SELECT 总分 INTO V_SCORE FROM SCORE WHERE 准考证号=P_ZKZH;
RETURN (V_SCORE);
EXCEPTION
WHEN OTHERS THEN
RETURN(-1);
END;
/
3. 返回院校名称函数GET_COLLEGE_NAME
CREATE OR REPLACE FUNCTION GET_COLLEGE_NAME (P_ZKZH VARCHAR2)
RETURN VARCHAR2
AS
V_NAME VARCHAR2(30);
BEGIN
SELECT 院校名称 INTO V_NAME FROM COLLEGE WHERE 院校代码=P_ZKZH;
RETURN (V_NAME);
EXCEPTION
WHEN OTHERS THEN
RETURN('无');
END;
/
创建存储过程
1. 【录入准考资格】存储过程INPUT_ZKZG
CREATE or replace PROCEDURE INPUT_ZKZG
(V_XM IN VARCHAR2, V_XB IN NUMBER,V_SFZH IN VARCHAR2, V_SF IN VARCHAR2, V_WLK IN VARCHAR2)
AS
R NUMBER;
BEGIN
SELECT COUNT(*) INTO R FROM STUDENT WHERE ×××号=V_SFZH;
IF R>0 THEN
DBMS_OUTPUT.PUT_LINE('考生'||V_XM||'的×××号码已经存在!');
ELSE
INSERT INTO STUDENT(准考证号,姓名,性别,×××号,省份,文理科)
VALUES(STUNO_SQU.NEXTVAL,V_XM,V_XB,V_SFZH,V_SF,V_WLK);
COMMIT;
DBMS_OUTPUT.PUT_LINE('考生'||V_XM||'准考信息录入成功!');
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('考生'||V_XM||'准考信息录入失败,该考生信息不正确!');
END;
/
执行存储过程:
EXECUTE INPUT_ZKZG('高飞云',1,429001198707266478,'黑龙江省', '1');
2. 【插入院校】存储过程INPUT_COLLEGE
CREATE OR REPLACE PROCEDURE INPUT_COLLEGE
(V_YXDM IN NUMBER,V_YXMC IN VARCHAR2,V_LQFSX IN NUMBER,V_ZSRS IN NUMBER)
AS
R NUMBER;
BEGIN
SELECT COUNT(*) INTO R FROM COLLEGE WHERE 院校代码=V_YXDM;
IF R>0 THEN
DBMS_OUTPUT.PUT_LINE('院校'||V_YXDM||'已经存在!');
ELSE
INSERT INTO COLLEGE
VALUES(V_YXDM,V_YXMC,V_LQFSX,V_ZSRS,0);
COMMIT;
DBMS_OUTPUT.PUT_LINE('院校'||V_YXMC||'插入成功!');
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('院校'||V_YXMC||'插入失败!');
END;
/
执行该存储过程:
EXECUTE INPUT_COLLEGE(1011,'吉林大学',570,6);
3. 【录入成绩】存储过程INPUT_LUFEN
CREATE OR REPLACE PROCEDURE INPUT_LUFEN
(V_ZKZH IN VARCHAR2, V_YWCJ IN NUMBER, V_SXCJ IN NUMBER, V_YYCJ IN NUMBER, V_ZHCJ IN NUMBER)
AS
L NUMBER;
M NUMBER;
N VARCHAR2(8);
BEGIN
SELECT COUNT(*) INTO L FROM TSCORE WHERE 准考证号=V_ZKZH;
SELECT COUNT(*) INTO M FROM student WHERE 准考证号=V_ZKZH;
SELECT 姓名 INTO N FROM STUDENT WHERE 准考证号=V_ZKZH;
IF M=1 and L=1 THEN
DBMS_OUTPUT.PUT_LINE('考生'||N||'成绩已经有了!');
ELSIF M=1 and L=0 THEN
INSERT INTO TSCORE
VALUES(V_ZKZH,V_YWCJ,V_SXCJ,V_YYCJ,V_ZHCJ);
UPDATE student SET 总分=V_YWCJ+V_SXCJ+V_YYCJ+V_ZHCJ where 准考证号=V_ZKZH;
COMMIT;
DBMS_OUTPUT.PUT_LINE('考生'||N||'成绩录入成功!');
DBMS_OUTPUT.PUT_LINE('考生'||N||'总分已经写入数据库!');
ELSE
DBMS_OUTPUT.PUT_LINE('系统错误!');
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('检查一下考号!');
END;
/
执行存储过程:
EXECUTE INPUT_LUFEN(201301420001,60,60,60,230);
4. 插入【报考志愿】存储过程INPUT_BKZY
CREATE OR REPLACE PROCEDURE INPUT_BKZY
(V_ZKZH IN VARCHAR2, V_ZY1 IN NUMBER,V_ZY2 IN NUMBER, V_TYTJ IN VARCHAR2)
AS
R NUMBER;
M NUMBER;
BEGIN
SELECT COUNT(*) INTO R FROM STUDENT WHERE 准考证号=V_ZKZH and 一志愿= V_ZY1;
SELECT COUNT(*) INTO M FROM COLLEGE WHERE 院校代码=V_ZY1;
IF R=1 and M=1 THEN
DBMS_OUTPUT.PUT_LINE('考生'||V_ZKZH||'已经填报志愿!');
ELSIF R=0 and M=1 THEN
Update student set 一志愿=V_ZY1,二志愿=V_ZY2,同意调剂=V_TYTJ where 准考证号=V_ZKZH;
COMMIT;
DBMS_OUTPUT.PUT_LINE('考生'||V_ZKZH||'志愿填报插入成功!');
ELSE DBMS_OUTPUT.PUT_LINE('考生'||V_ZKZH||'失败!');
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('考生'||V_ZKZH||'志愿插入失败!');
END;
/
执行存储过程:
EXECUTE INPUT_BKZY(201301420001,1011,1012,'0');
5. 投档初始化过程CLEARSTATUS
CREATE OR REPLACE PROCEDURE CLEARSTATUS
AS
BEGIN
UPDATE COLLEGE SET 录取人数=0;
UPDATE STUDENT SET 录取状态=0,录取志愿=NULL,录取院校=NULL,录取日期=NULL,操作人=NULL;
COMMIT;
END;
/
6. 一志愿投档存储过程PROC1
CREATE OR REPLACE PROCEDURE PROC1(P_YXDM NUMBER)
AS
V_ZSRS NUMBER(3);
V_LQFSX NUMBER(3);
V_YXMC VARCHAR2(30);
V_COUNT NUMBER(3);
CURSOR STU_CURSOR IS SELECT * FROM STUDENT
WHERE 一志愿=P_YXDM ORDER BY 总分 DESC;
BEGIN
SELECT 招生人数,录取分数线,院校名称 INTO V_ZSRS,V_LQFSX,V_YXMC
FROM COLLEGE WHERE 院校代码=P_YXDM;--取院校信息
V_COUNT:=0;
DBMS_OUTPUT.PUT_LINE('院校名称:'||V_YXMC||'一志愿投档开始');
DBMS_OUTPUT.PUT_LINE('--------------------- ----------------------------');
FOR STU_REC IN STU_CURSOR LOOP
EXIT WHEN V_COUNT>=V_ZSRS;
IF(STU_REC.总分>=V_LQFSX) THEN
UPDATE STUDENT SET 录取状态='1',录取志愿='1',录取院校=P_YXDM,录取日期=SYSDATE,操作人=USER WHERE 准考证号= STU_REC.准考证号;
DBMS_OUTPUT.PUT_LINE(' 准考证号:'|| STU_REC.准考证号||' 姓名:'||STU_REC.姓名||' 总分:'|| STU_REC.总分);V_COUNT:=V_COUNT+1;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('------------------------------------------------------------');
UPDATE COLLEGE SET 录取人数=V_COUNT WHERE 院校代码=P_YXDM;
COMMIT;
END;
/
7. 二志愿投档存储过程PROC2
CREATE OR REPLACE PROCEDURE PROC2(P_YXDM NUMBER)
AS
V_ZSRS NUMBER(3);
V_LQFSX NUMBER(3);
V_YXMC VARCHAR2(30);
V_LQRS NUMBER(3);
V_COUNT NUMBER(3);
CURSOR STU_CURSOR IS
SELECT * FROM STUDENT
WHERE 二志愿=P_YXDM AND 录取状态=0
ORDER BY 总分 DESC;
BEGIN
SELECT 招生人数,录取分数线,录取人数,院校名称 INTO V_ZSRS,V_LQFSX,V_LQRS,V_YXMC
FROM COLLEGE WHERE 院校代码=P_YXDM;
V_COUNT:=V_LQRS;
DBMS_OUTPUT.PUT_LINE('院校名称:'||V_YXMC||'二志愿投档开始');
DBMS_OUTPUT.PUT_LINE('------------------------------ -------------------');
FOR STU_REC IN STU_CURSOR LOOP
EXIT WHEN V_COUNT>=V_ZSRS;
IF(STU_REC.总分>=V_LQFSX) THEN
UPDATE STUDENT SET 录取状态='1',录取志愿='2',录取院校=P_YXDM,录取日期=SYSDATE, 操作人=USER WHERE 准考证号= STU_REC.准考证号;
DBMS_OUTPUT.PUT_LINE(' 准考证号:'|| STU_REC.准考证号||' 姓名:'||STU_REC.姓名||' 总分:'|| STU_REC.总分); V_COUNT:=V_COUNT+1;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('------------------------------------------------------------');
UPDATE COLLEGE SET 录取人数=V_COUNT WHERE 院校代码=P_YXDM;
COMMIT;
END;
/
8. 自动投档程序AUTOPROC
CREATE OR REPLACE PROCEDURE AUTOPROC(P_LQZY NUMBER)
AS
CURSOR COLLEGE_CURSOR IS SELECT 院校代码 FROM COLLEGE;
BEGIN
FOR COLLEGE_REC IN COLLEGE_CURSOR LOOP
IF (P_LQZY=1) THEN
PROC1(COLLEGE_REC.院校代码);
ELSIF (P_LQZY=2) THEN
PROC2(COLLEGE_REC.院校代码);
END IF;
END LOOP;
END;
/
9. 查询考生分数过程SHOW_SCORE
CREATE OR REPLACE PROCEDURE SHOW_SCORE(P_ZKZH VARCHAR2)
AS
V_SCORE NUMBER(3);
BEGIN
V_SCORE:= GET_SCORE(P_ZKZH);
IF V_SCORE=-1 THEN
DBMS_OUTPUT.PUT_LINE('考生准考证号错误!');
ELSE
DBMS_OUTPUT.PUT_LINE(''||GET_STUDENT_NAME(P_ZKZH)||'总分'||V_SCORE);
END IF;
END;
/
10. 查询考生录取状态过程SHOW_RESULT
CREATE OR REPLACE PROCEDURE SHOW_RESULT(P_ZKZH VARCHAR2)
AS
V_LQYXMC VARCHAR2 (20);
V_XM VARCHAR2(10);
BEGIN
V_XM:= GET_STUDENT_NAME(P_ZKZH);
IF V_XM = '无' THEN
DBMS_OUTPUT.PUT_LINE('考生准考证号错误!');
ELSE
SELECT 录取院校名称 INTO V_LQYXMC FROM RESULT WHERE 准考证号=P_ZKZH;
DBMS_OUTPUT.PUT_LINE('考生'||V_XM||'被'||V_LQYXMC||'录取!');
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('考生'|| V_XM ||'未被录取!');
END;
/
9.显示院校录取名册存储过程STUDENT_LIST
CREATE or replace PROCEDURE STUDENT_LIST(P_YXDM NUMBER)
AS
V_SNAME VARCHAR2(10);
V_MAX NUMBER(3);
V_MIN NUMBER(3);
COL_REC COLLEGE%ROWTYPE;
CURSOR STU_CURSOR IS SELECT * FROM STUDENT WHERE 录取院校=P_YXDM ORDER BY 总分 DESC;
BEGIN
SELECT * INTO COL_REC FROM COLLEGE WHERE 院校代码=P_YXDM;
DBMS_OUTPUT.PUT_LINE(GET_COLLEGE_NAME(P_YXDM)||'院校录取统计表');
DBMS_OUTPUT.PUT_LINE(' 招生人数:'||COL_REC.招生人数||' 录取人数:'||COL_REC.录取人数||' 录取分数线:'||COL_REC.录取分数线);
DBMS_OUTPUT.PUT_LINE('----------------------------------------------------------------------');
DBMS_OUTPUT.PUT_LINE('序号 考生准考证号 姓名 性别 总分 录取志愿 录取日期');
FOR STU_REC IN STU_CURSOR LOOP
IF STU_REC.性别=1 THEN
DBMS_OUTPUT.PUT_LINE(RPAD(STU_CURSOR%ROWCOUNT,8,' ')||RPAD(STU_REC.准考证号,9,' ')||RPAD(STU_REC.姓名,9,' ')||'男 '||RPAD(STU_REC.总分,9,' ')||RPAD(STU_REC.录取志愿,9,' ')||RPAD
(STU_REC.录取日期,9,' '));
ELSE
DBMS_OUTPUT.PUT_LINE(RPAD(STU_CURSOR%ROWCOUNT,8,' ')||RPAD(STU_REC.准考证号,9,' ')||RPAD(STU_REC.姓名,9,' ')||'女 '||RPAD(STU_REC.总分,9,' ')||RPAD(STU_REC.录取志愿,9,' ')||RPAD
(STU_REC.录取日期,9,' '));
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('--------------------------------------------------------------------');
SELECT MAX(总分),MIN(总分) INTO V_MAX,V_MIN FROM STUDENT
WHERE 录取院校=P_YXDM;
DBMS_OUTPUT.PUT_LINE(' 最高分'||V_MAX||' 最低分:'||V_MIN);
END;
/
11. 院校招生情况统计表 COLLEGE_TOTAL
CREATE OR REPLACE PROCEDURE COLLEGE_TOTAL
AS
V_YXDM NUMBER(4);
V_AVG NUMBER(4);
V_MAX NUMBER(4);
V_MIN NUMBER(4);
V_BOY NUMBER(3);
V_GIRL NUMBER(3);
V_ZSRS NUMBER(3);
V_LQRS NUMBER(3);
V_YXMC VARCHAR2(20);
CURSOR STU_CURSOR IS
SELECT 录取院校,AVG(总分),MAX(总分),MIN(总分) FROM STUDENT GROUP BY 录取院校 ORDER BY AVG(总分) DESC;
BEGIN
DBMS_OUTPUT.PUT_LINE('院校代码 院校名称 招生人数 录取人数 男生人数 女生人数 最高分数 最低分数 平均分数');
OPEN STU_CURSOR;
LOOP
FETCH STU_CURSOR INTO V_YXDM,V_AVG,V_MAX,V_MIN;
EXIT WHEN STU_CURSOR%NOTFOUND;
IF V_YXDM IS NOT NULL THEN
SELECT 院校名称,招生人数,录取人数 INTO V_YXMC,V_ZSRS,V_LQRS
FROM COLLEGE WHERE 院校代码=V_YXDM;
SELECT COUNT(*) INTO V_BOY FROM STUDENT WHERE 录取院校=V_YXDM AND 性别=1;
SELECT COUNT(*) INTO V_GIRL FROM STUDENT WHERE 录取院校=V_YXDM AND 性别=2;
DBMS_OUTPUT.PUT_LINE(RPAD(V_YXDM,8,' ')||RPAD(V_YXMC,18,' ')||RPAD(V_ZSRS,9,' ')||RPAD(V_LQRS,9,' ')||RPAD(V_BOY,9,' ')||RPAD(V_GIRL,9,' ')||RPAD(V_MAX,9,' ')||RPAD(V_MIN,9,' ')||RPAD(V_AVG,9,' '));
END IF;
END LOOP;
CLOSE STU_CURSOR;
END;
/
触发器的设计
步骤1:创建如下的记录表OPERATION_LOGS:
CREATE TABLE OPERATION_LOG(
序号 NUMBER(10) PRIMARY KEY,
账户 VARCHAR2(15) NOT NULL,
时间 DATE,
操作 VARCHAR2(10),
考生准考证号 VARCHAR2(12),
原分数 NUMBER(3),
新分数 NUMBER(3)
);
步骤2:创建一个主键序列OPERATION_ID:
CREATE SEQUENCE OPERATION_ID INCREMENT BY 1
START WITH 1 MAXVALUE 201399999999 NOCYCLE NOCACHE;
步骤3:创建和编译以下触发器:
CREATE or replace TRIGGER OPERATION
BEFORE
DELETE OR INSERT OR UPDATE OF 总分 ON STUDENT
FOR EACH ROW
BEGIN
IF INSERTING THEN
INSERT INTO OPERATION_LOG
VALUES(OPERATION_ID.NEXTVAL,USER,SYSDATE,'插入',:NEW.准考证号,NULL,:NEW.总分);
ELSIF DELETING THEN
INSERT INTO OPERATION_LOG
VALUES(OPERATION_ID.NEXTVAL,USER,SYSDATE,'删除',:OLD.准考证号,:OLD.总分,NULL);
ELSE
INSERT INTO OPERATION_LOG
VALUES(OPERATION_ID.NEXTVAL,USER,SYSDATE,'修改',:OLD.准考证号,:OLD.总分,:NEW.总分);
END IF;
END;
/
2. 级联修改触发器
CREATE OR REPLACE TRIGGER UPDATE_COLLEGE
AFTER
UPDATE OF 院校代码
ON COLLEGE
FOR EACH ROW
BEGIN
UPDATE STUDENT SET 一志愿=:NEW.院校代码 WHERE 一志愿=:OLD.院校代码;
UPDATE STUDENT SET 二志愿=:NEW.院校代码 WHERE 二志愿=:OLD.院校代码;
UPDATE STUDENT SET 录取院校=:NEW.院校代码 WHERE 录取院校=:OLD.院校代码;
END;
/
系统的测试和运行
1. 按姓名进行模糊查询
查找姓王的考生:
SELECT 准考证号,姓名,性别,总分 FROM STUDENT WHERE 姓名 LIKE '高%';
2.按分数或分数段进行查询
查询分数在600~650分之间的考生:
SELECT 准考证号,姓名,性别,总分 FROM STUDENT WHERE 总分>600 AND 总分<650;
3.查询分数最高的考生报考的院校
查询分数最高的考生一志愿报考的院校:
SELECT 准考证号,姓名,性别,总分,院校名称 FROM STUDENT S,COLLEGE C WHERE S.一志愿=C.院校代码 AND S.总分=(SELECT MAX(总分) FROM STUDENT);
4.查询招生人数最多的院校
SELECT 院校名称,招生人数 FROM COLLEGE WHERE 招生人数=(SELECT MAX(招生人数) FROM COLLEGE);
5.查询考生分数
EXEC SHOW_SCORE(201301420001);
6.检查OPERATION触发器的记录
SELECT * FROM OPERATION_LOG;
执行结果:
...
100 STUDENT 28-3月 -04 插入 10048 550
101 STUDENT 28-3月 -04 插入 10049 630
4.2 投档过程
1.初始化
SET SERVEROUTPUT ON SIZE 10000;
EXEC CLEARSTATUS;
2.一志愿自动投档
一志愿自动投档程序为:
EXEC AUTOPROC(1);
3.查询考生录取状态
EXEC SHOW_RESULT(201301420001);
4.二志愿自动投档
EXEC AUTOPROC(2);
5.查询录取情况视图
SELECT * FROM STATUS;
4.3 统计报表
1.院校录取考生列表
显示深圳职业技术学院的录取考生列表,并按成绩排序:
EXEC STUDENT_LIST(1010);
2.招生情况统计
显示按平均分降序排列的招生情况统计表:
EXEC COLLEGE_TOTAL;
4.4 结果分析
检查没有被录取的考生一志愿报考的院校:
SELECT 准考证号,姓名,总分,院校名称 FROM STUDENT S,COLLEGE C
WHERE S.一志愿=C.院校代码 AND S.录取志愿 IS NULL ORDER BY 总分 DESC;
SELECT * FROM STUDENT WHERE 准考证号=201301420047;
SELECT * FROM COLLEGE WHERE 院校代码=1005;
复旦大学虽然没有招满,但因该考生的分数低于复旦大学的录取分数线,所以一志愿落选正常。继续检查二志愿情况:
SELECT * FROM COLLEGE WHERE 院校代码=1006;
执行结果:
院校代码 院校名称 录取分数线 招生人数 录取人数
--------------- ---------------------------------------------- ---------------- ----------------
1007 华南理工大学 520 4 4
SELECT 准考证号,姓名,总分,录取志愿 FROM STUDENT WHERE 录取院校=1006 ORDER BY 总分 DESC;
执行结果:
准考证号 姓名 总分
--------------- ------------------------------- ----------
10017 罗惯通 585 1
10046 胡月 557 1
10006 杨煌 555 2
10041 林晨曦 532 1
存储过程代码 见附件