📄 test.sql
字号:
/*
* 下面的SQL脚本仅仅适用于Oracle
*/
/* 学生基本信息 */
drop table test_studentinfo;
/* 考试结果信息 */
drop table test_result;
/* 教师和管理员帐号 */
drop table test_admin;
/* 班级信息 */
drop table test_classinfo;
/* 题库 */
drop table test_question_lib;
/* 试卷 */
drop table test_paper_lib;
/* 以下sequence用来产生一些表的主键 */
drop sequence test_seq_student;
drop sequence test_seq_result;
drop sequence test_seq_classinfo;
drop sequence test_seq_question;
drop sequence test_seq_paper;
/************************************************************************
* 参加入学测试的学生基本信息
* 注: 有些字段值未必在登记时就输入,可能是在学生入学后才输入
************************************************************************
*/
create table test_studentinfo(
/* 个人信息 */
studentid number(6,0) primary key, /* 学生编号,自动生成 */
name varchar(8), /* 姓名 */
certid varchar(18), /* 身份证号码 */
password varchar(20), /* 密码 */
gender varchar(2), /* 性别 */
birth date, /* 出生日期 */
phone varchar(60), /* 联系电话 */
email varchar(40), /* email地址 */
hometown varchar(40), /* 籍贯 */
hukou varchar(40), /* 户口所在地 */
txdz varchar(40), /* 通信地址 */
yzbm varchar(40), /* 邮政编码 */
/* 下面为工作和教育背景 */
school varchar(40), /* 毕业学校 */
major varchar(20), /* 专业 */
g_time varchar(20), /* 毕业时间 */
degree varchar(8), /* 最高学历 */
english varchar(10), /* 英语水平 */
work_year varchar(10), /* 工作年限 */
/* 以下为其他信息 */
shixi varchar(2), /* 是否需要实习 */
tjgz varchar(2), /* 是否需要推荐工作 */
goal varchar(20), /* 参加培训目的和期望 */
source varchar(20), /* 信息来源 */
regtime date /* 填表日期 */
);
/* 创建序列test_seq_student */
create sequence test_seq_student maxvalue 9999999;
/************************************************************************
* 创建管理员信息表, 此表保存教师和管理员信息
************************************************************************
*/
create table test_admin(
loginname varchar(8) primary key, /* 管理人员登录名 */
truename varchar(8) , /* 管理人员真实姓名 */
password varchar(8),
priviledge int /* 1为查看考生成绩,填写面试结果 8 为系统维护权限 */
);
/***********************************************************************
* 测试结果
***********************************************************************
*/
create table test_result(
testid number(6,0) primary key, /* 测试结果编号 */
studentid number(6,0) , /* 学生编号 */
score int, /* 测试成绩 */
starttime date, /* 测试时间 */
classid varchar(2), /* 班级代号 */
teachername varchar(8), /* 参加面试教师登录名 */
mianshif int, /* 面试分数 */
mianshij int, /* 面试结果 */
suggest varchar(50), /* 面试教师建议 */
baoming varchar(2), /* 是否报名 */
classname varchar(10) /* 报名班级 */
);
/* 创建序列test_seq_result */
create sequence test_seq_result maxvalue 9999999;
/************************************************************************
* 创建课程信息表
************************************************************************
*/
create table test_classinfo(
classid varchar(2) primary key, /* 课程代号 */
classname varchar(30), /* 课程名称 */
totaltime number(2,0), /* 考试时间 */
totalques number(2,0), /* 考题数目 */
totalpaper number(2,0) /* 试卷数目 */
);
/* 创建序列test_seq_classinfo */
create sequence test_seq_classinfo maxvalue 9999999;
/************************************************************************
* 创建题库定义信息表
************************************************************************
*/
create table test_question_lib(
questionid number(6,0) primary key, /* 题目编号 */
selectid number(2,0), /* 题型信息:1-单选 ; 2-多选 */
classid varchar(2), /* 课程代号:20-JAVA编程 ; 30-JSP编程 ;40-ASP编程 */
qname varchar(2000), /* 题目 */
choice1 varchar(500), /* 选项1 */
choice2 varchar(500), /* 选项2 */
choice3 varchar(500), /* 选项3 */
choice4 varchar(500), /* 选项4 */
answer varchar(4) /* 答案 */
);
/* 创建序列test_seq_question */
create sequence test_seq_question maxvalue 9999999;
/************************************************************************
* 每次都是从题库中随机抽取试题,动态形成试卷
* 创建试卷定义信息表
************************************************************************
*/
create table test_paper_lib(
id number(6,0) primary key, /* id : Primary key */
paper_id number(6,0), /* 试卷编号 */
questionid number(6,0) /* 题目编号 */
);
/* 创建序列test_seq_paper */
create sequence test_seq_paper maxvalue 9999999;
create or replace view test_paper_info
as
select distinct test_paper_lib.paper_id,test_paper_lib.questionid,
test_question_lib.selectid,test_question_lib.classid,test_classinfo.classname,
test_question_lib.qname,test_question_lib.choice1,
test_question_lib.choice2,test_question_lib.choice3,
test_question_lib.choice4,test_question_lib.answer
from test_paper_lib,test_question_lib,test_classinfo
where test_paper_lib.questionid = test_question_lib.questionid and test_classinfo.classid=test_question_lib.classid;
create or replace view test_result_info
as
select test_studentinfo.studentid,test_studentinfo.name,test_studentinfo.certid,
test_studentinfo.gender,test_studentinfo.birth,test_studentinfo.school,
test_studentinfo.major,test_studentinfo.g_time,test_studentinfo.degree,
test_studentinfo.english,test_studentinfo.work_year,
test_result.score,test_result.starttime,
test_result.classid,test_result.testid,
test_result.mianshij
from test_studentinfo,test_result
where test_studentinfo.studentid = test_result.studentid;
insert into test_classinfo values ('20','Java 高级程序设计' ,30,20,0);
insert into test_classinfo values ('30','计算机网络基本理论' ,30,30,0);
insert into test_classinfo values ('40','平面美术设计与技能',30,30,0);
insert into test_admin values ('admin', '左非','admin',8);
insert into test_admin values ('susan', '苏燕','ssss',1);
insert into test_admin values ('john' , '常江','jjjj',1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -