实验七 SQL和数据库管理综合练习和答案(2)

2018-11-24 17:34

表已创建。

SQL> create table course 2 (

3 cno varchar2(10),

4 cname varchar2(10) not null, 5 credit number(2) not null,

6 constraint course_cno_pk primary key(cno),

7 constraint course_credit_ck check(credit in('2','3','4','5','6')) 8 )

9 tablespace yxm39tablespace;

表已创建。

SQL> create table score 2 (

3 sno varchar2(10) references student(sno), 4 cno varchar2(10) references course(cno),

5 grade number(3,1) not null check(grade between 0 and 100), 6 primary key(sno,cno) 7 )

8 tablespace yxm39tablespace;

表已创建。

SQL> insert into student(sno,sname,sage)values('s001' ,'mike' ,20 );

已创建 1 行。

SQL> insert into student(sno,sname,sage)values('s002' ,'jerry' ,19 );

已创建 1 行。

SQL> insert into student(sno,sname,sage)values('s003' ,'tom' ,20 );

已创建 1 行。

SQL> insert into course(cno,cname,credit)values('c001','oracle',4 );

已创建 1 行。

SQL> insert into course(cno,cname,credit)values('c002' ,'java' ,4 );

已创建 1 行。

SQL> insert into course(cno,cname,credit)values('c003' ,'c++' ,6 );

已创建 1 行。

SQL> insert into score(sno,cno,grade)values('s001' ,'c001' ,80 );

已创建 1 行。

SQL> insert into score(sno,cno,grade)values('s001' ,'c002' ,90 );

已创建 1 行。

SQL> insert into score(sno,cno,grade)values('s002' ,'c001' ,85 );

已创建 1 行。

SQL> create unique index yxm39index on course(cname) tablespace yxm39tablespace;

索引已创建。

SQL> conn system/sys@orcl 已连接。

SQL> create synonym semp for scott.emp;

同义词已创建。

SQL> create synonym sdept for scott.dept;

同义词已创建。

SQL> create table empbak as(select * from scott.emp);

表已创建。

SQL> create table deptbak as(select * from scott.dept);

表已创建。

SQL> create view yxm39view1 as

2 (select s.sno,s.sname,sc.cno,c.cname from student s,score

sc,course c

3 where s.sno=sc.sno(+) and sc.cno=c.cno(+));

视图已创建。

SQL> create view yxm39view2 as

2 (select s.sno,s.sname,sc.cno,c.cname,c.credit,sc.grade 3 from student s,score sc,course c

4 where s.sno=sc.sno(+) and sc.cno=c.cno(+));

视图已创建。

SQL> create view yxm39view3 as 2 (

3 select s.sno,s.sname,avg(grade) 平均成绩 from student s,score sc 4 where s.sno=sc.sno

5 group by s.sno,sc.grade,s.sname);

视图已创建。

SQL> create view yxm39view4 as

2 (select * from course where(cno not in(select cno from score)));


实验七 SQL和数据库管理综合练习和答案(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:单相桥式整流电路纯电阻负载课程设计

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: