/************************************************************************ 
 * 创建课程信息表 
 ************************************************************************
 */
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 ('susanna','张燕','ssss',1);
insert into test_admin values ('john'   ,'刘江','jjjj',1);