要求:
使用plsql完成一个简单的系统设计开发。
详细信息:
学生表:学号、姓名、年龄、性别、年级、入学日期。
教师表:教师号、姓名、年龄。
选课表:学号、课程号、课程名、教师号、课程学分。
成绩表:学号、学生姓名、课程名、成绩。
账户表:账户名(学号)、账户密码
状态记录表 :时间,用户名,状态号,状态
各个表之间的关系:
学生表 成绩表 学号
学生表 选课表 学号
选课表 教师 教师号
账户表 学生表 学号
功能:
包含:视图,登录,注册,触发器,记录操作,分页查询,游标,事件,日志
1.注册,检测是否已注册 ,注册时记录注册状态, 注册时如果不是学生表中的学生,禁止注册
2.登录,检测账户是否存在,存在即登录,不存在提示注册,同时记录登录状态
3.触发器,限制注册时段,只能在工作日上班时间注册
4.用户登陆与注册时记录用户状态的信息
5.用户对学生表进行操作时,记录操作信息(没有写入日志)
6.用户必须登录后才能对学生信息表进行插入,删除和修改操作
7.分页查询 查询学生表数据(指定查询从第几行开始的几条数据),分页展示
8.创建视图统计每个学生的学分情况,并使用plsql查询指定学生的学分情况(使用游标)
9.使用plsql求每年入学学生数量和男女比例+视图
10.使用plsql求成绩高于选修同一课程的所有学生的平均成绩的学生姓名、性别、账户密码(未注册也算)、课程名、成绩以及学生所报的课程学分,结果按照学号正序排序,以便查看学生所报课程。
11.使用plsql查询所指定的表哪一列哪一行所唯一确定的一个数据
12.使用plsql修改表数据,符合条件的数据进行修改。指定修改某张表的指定字段的全部要修改的数据。
一、创表并插入数据
插入数据前修改日期格式
select *from v$nls_parameters;
alter session set NLS_DATE_FORMAT='yyyy-mm-dd';
student 学生表:
create table student(
sno varchar2(5) not null primary key,
sname varchar2(12) not null,
age number(2) not null,
sex varchar(5) not null,
beanch varchar2(20) not null,
entrance date not null
);
insert into student(sno,sname,age,sex,beanch,entrance) values (10001,'Tom',18,'男','大一','2016-01-01');
insert into student(sno,sname,age,sex,beanch,entrance) values (10002,'jack',19,'男','大一','2016-09-02');
insert into student(sno,sname,age,sex,beanch,entrance) values (10003,'rose',17,'女','大一','2015-02-05');
insert into student(sno,sname,age,sex,beanch,entrance) values (10004,'smith',21,'男','大二','2014-03-01');
insert into student(sno,sname,age,sex,beanch,entrance) values (10005,'allen',18,'男','大一','2016-02-18');
insert into student(sno,sname,age,sex,beanch,entrance) values (10006,'jones',19,'男','大三','2015-01-11');
insert into student(sno,sname,age,sex,beanch,entrance) values (10007,'mar',18,'女','大一','2014-05-07');
insert into student(sno,sname,age,sex,beanch,entrance) values (10008,'admn',20,'女','大四','2014-01-28');
insert into student(sno,sname,age,sex,beanch,entrance) values (10009,'nike',22,'男','大一','2016-06-12');
insert into student(sno,sname,age,sex,beanch,entrance) values (10010,'martin',17,'女','大一','2014-03-09');
insert into student(sno,sname,age,sex,beanch,entrance) values (10011,'wangchen',22,'男','大四','2014-09-01');
commit;
teacher 教师表:
create table teacher(
tno varchar2(5) not null primary key,
tname varchar2(12) not null,
age number(2)
);
insert into teacher(tno,tname,age) values('01','张飞',60);
insert into teacher(tno,tname,age) values('02','赵云',50);
insert into teacher(tno,tname,age) values('03','关羽',40);
insert into teacher(tno,tname