山东大学软件学院数据库实验1-9(全部)

目录

前言

实验代码

实验一

1-1

1-2 

1-3 

1-4 

1-5 

1-6 

实验二

2-1

 2-2

2-3 

2-4

2-5 

2-6

2-7

2-8

2-9

2-10

实验三 

3-1

3-2

3-3

3-4

3-5

3-6

3-7

3-8

3-9

3-10

实验四 

4-1

4-2

4-3

4-4

4-5

4-6

4-7

4-8

4-9

4-10

实验五 

5-1

5-2

5-3

5-4

5-5

5-6

5-7

5-8

5-9

5-10

实验六 

6-1

6-2

6-3

6-4

6-5

6-6

6-7

6-8

6-9

6-10

 实验七

7-1

7-2

7-3

7-4

7-5

实验八 

实验九 

9-1

9-2

更详细题目讲解


前言

这个是2023年山东大学软件学院数据库实验,使用的数据库管理系统为oracle

实验代码全部通过,并且已经拿到满分,但是还是希望学弟学妹们能够参考着去完成自己的实验,而不是直接copy。因为完成实验能够大大提高我们写sql的能力,这可不是看看书能比的哦!

2024年甚至更远的未来的同学们参考时要留一个心眼,因为每一年实验的题目都会有一点点的变化,要仔细阅读题目要求。

实验代码

实验一

1-1

create table test1_student(
       sid char(12) not null,
       name varchar(10) not null,
       sex char(2),
       age int,
       birthday date,
       dname varchar(30),
       class varchar(10)
);

1-2 

create table test1_course(
       cid char(6) not null,
       name varchar(40) not null,
       fcid char(6),
      credit numeric(4,1)
)

1-3 

create table test1_student_course(
      sid char(12) not null,
      cid char(6) not null,
      score numeric(5,1),
      tid char(6),
      sctime date
);

1-4 

insert into test1_student values('201800020101','王欣','女',21,to_date('19940202','yyyymmdd'),'计算机学院','2010');
 
insert into test1_student values('201800020102','李华','女',20,to_date('19950303','yyyymmdd'),'软件学院','2009');

1-5 

insert into test1_course values('800001','数据结构',null,2);
insert into test1_course values('800002','数据库',800001,2.5)

1-6 

insert into test1_student_course values
     ('201800020101','300001',91.5,'200101',
      to_date(' 2009-07-15 09:09:09','yyyy-mm-dd hh24-mi-ss'));
 
insert into test1_student_course values
     ('201800020101','300002',92.6,'200102',
      to_date(' 2009-07-15 10:10:10','yyyy-mm-dd hh24-mi-ss'));

实验二

2-1

create view test2_01 as
  select sid,name
  from pub.student
  where sid not in
  (
    select distinct sid
    from pub.student_course
  )

 2-2

create view test2_02 as
  select sid,name
  from pub.student
  where sid in
  (
    select sid
    from pub.student_course
    where cid in
      (
        select cid
        from pub.student_course
        where sid='200900130417'
      )
  )
  minus
  (
    select sid, name
		from pub.student
		where sid ='200900130417'
  )

2-3 

create view test2_03 as
  select sid,name
  from pub.student
  where sid in
  (
    select sid
    from pub.student_course
    where cid in
    (
       select cid
       from pub.course
       where fcid='300002'
    )
  )

2-4

create view test2_04 as
  select sid,name
  from pub.student
  where sid in
  (
    (
      select sid
      from pub.student_course
      where cid=(
        select cid
        from pub.course
        where name='操作系统'
      )
    )
    intersect
    (
      select sid
      from pub.student_course
      where cid=(
        select cid
        from pub.course
        where name='数据结构'
      )
    )
    minus
    (
      select sid
      from pub.student_course
      where cid=(
        select cid
        from pub.course
        where name='程序设计语言'
      )
    )
  )

2-5 

create view test2_05 as
  select sid,cid,name,score
  from pub.student_course natural join pub.course
  where sid in
  (
    select sid
    from pub.student
    where name='李龙'
  )

2-6

create view test2_06 as
  select sid,name,score
  from pub.student_course natural join pub.student
  where class='2010' and dname='计算机科学与技术学院' and cid=(
    select cid
    from pub.course
    where name='操作系统'
  )

2-7

create view test2_07 as
select sid,name
from pub.student
where name not like '张%'
and name not like '李%'
and name not like '王%'

2-8

create view test2_08 as
select cid,name
from pub.course
where fcid in(
  select cid
  from pub.course
  where fcid is not null
)

2-9

create view test2_09 as
select sid,name,score
from pub.student_course natural join pub.student
where cid='300003'

2-10

create view test2_10 as
select sid,name
from pub.student
where not exists(
  select cid
  from pub.course
  where not exists(
    select *
    from pub.student_course
    where pub.student_course.sid=pub.student.sid and pub.student_course.cid=pub.course.cid
  )
)

实验三 

3-1

create table test3_01 as
	select *
	from pub.student_31
delete from test3_01
where sid not in
	(select sid
	from test3_01
	where regexp_like(sid, '^[0-9]+$')) --检验字符串是否是全数字

3-2

create table test3_02 as
	select *
	from pub.student_31
delete from test3_02
where age <> 2012 - extract(year from birthday)

3-3

create table test3_03 as
	select *
	from pub.student_31

delete from test3_03
where sex <> '男' and sex <> '女' and sex is not null

3-4

create table test3_04 as
	select *
	from pub.student_31
delete from test3_04 
where dname like '% %' or
dname is null or
length(dname) < 3

3-5

create table test3_05 as
	select *
	from pub.student_31
delete
from test3_05
where class not in
	(select class
	from test3_05
	where regexp_like(class, '^[0-9]+$'))

3-6

create table test3_06 as
	select *
	from pub.student_31
delete
from test3_06
where not regexp_like(sid, '^[0-9]+$')
or age <> 2012 - extract(year from birthday)
or name like '% %'
or length(name) < 2
or sex in
	(select distinct sex
	from test3_06
	where sex <> '男'
		and sex <> '女'
		and sex is not null)
or dname like '% %'
or dname is null
or length(dname) < 3
or class not in
	(select class
	from test3_05
	where regexp_like(class, '^[0-9]+$'))

3-7

create table test3_07 as
	select *
	from pub.student_course_32
delete 
from test3_07
where sid not in(
  select sid
  from pub.student
)

3-8

create table test3_08 as
	select *
	from pub.student_course_32
delete 
from test3_08 T
where not exists(
  select cid, tid
  from pub.teacher_course A
  where T.cid=A.cid and T.tid=A.tid
)

3-9

create table test3_09 as
	select *
	from pub.student_course_32
delete
from test3_09
where score not between 0 and 100

3-10

create table test3_10 as
	select *
	from pub.student_course_32
delete
from test3_10 S
where sid not in
	(select sid
	from pub.student)
or cid not in
	(select cid
	from pub.course)
or tid not in
	(select tid
	from pub.teacher)
or not exists
	(select cid, tid
	from pub.teacher_course T
	where S.cid = T.cid
	and S.tid = T.tid)
or score not between 0 and 100

实验四 

4-1

create table test4_01 as
  select * from pub.student_41
 
alter table test4_01
  add sum_score int
 
update test4_01 S
  set sum_score=(
    select sum(score)
    from pub.student_course T
    where S.sid=T.sid
  )

4-2

create table test4_02 as
  select * from pub.student_41
 
alter table test4_02
  add avg_score numeric(3,1)
 
update test4_02 S
  set avg_score=(
    select avg(score)
    from pub.student_course T
    where S.sid=T.sid
  )

4-3

create table test4_03 as
  select * from pub.student_41
 
alter table test4_03
  add sum_credit int
 
update test4_03 S
  set sum_credit=(
    select sum(credit)
    from pub.course
    where cid in(
      select distinct cid
      from pub.student_course SC
      where S.sid=SC.sid
      and SC.score>=60
    )
  )

4-4

create table test4_04 as
  select * from pub.student_41
 
update test4_04 T
set dname=(
  select did
  from pub.department D
  where T.dname=D.dname
)
where T.dname in(
  select dname
  from pub.department
)

4-5

create table test4_05 as
  select * from pub.student_41
 
alter table test4_05 
  add sum_score int
 
alter table test4_05 
  add avg_score numeric(3, 1)
 
alter table test4_05 
  add sum_credit int
 
alter table test4_05 
  add did varchar(2)
update test4_05 T
set 
  sum_score=(
    select sum(score)
  	from pub.student_course SC
  	where T.sid = SC.sid
  ),
  avg_score=(
    select avg(score)
    from pub.student_course SC
    where T.sid=SC.sid
  ),
  sum_credit=(
    select sum(credit)
    from pub.course
    where cid in(
      select distinct cid
      from pub.student_course SC
      where T.sid=SC.sid
      and SC.score>=60
      )
   )
 
update test4_05 T
set did=(
    select did
    from (
      select did,dname
      from pub.department
    union
      select did,dname
      from pub.department_41
    ) department
    where T.dname=department.dname
  )
 
update test4_05
set did='00'
where did is null;

4-6

create table test4_06 as
  select * from pub.student_42
update test4_06
set name=replace(name,' ','')

4-7

create table test4_07 as
  select * from pub.student_42

update test4_07
set sex= replace( sex,' ','')
 
update test4_07
set sex= replace( sex,'性','')

4-8

create table test4_08 as
  select * from pub.student_42

update test4_08
set class=replace(class,'级','');

4-9

create table test4_09 as
  select * from pub.student_42

update test4_09 T
set age=(
  select 2012-extract (year from birthday)
  from test4_09 S
  where T.sid=S.sid
  )
where T.age is null;

4-10

create table test4_10 as
select *
from pub.student_42;
 
update test4_10
set name=replace(name,' ','');
 
update test4_10
set dname=replace(dname,' ','');
 
update test4_10
 set age=(
select (2012-extract (year from birthday))
from pub.student_42
where test4_10.sid=sid
)
where test4_10.age is null;
 
update test4_10
set sex= replace( sex,' ','');
update test4_07
set sex= replace( sex,'性','');
 
update test4_10
set class=replace(class,'级','');

实验五 

5-1

create table test5_01(
  First_name varchar(4),
  frequency numeric(4)
)
insert into test5_01(
  select substr(name,2),count(*)
  from pub.student
  group by substr(name,2)
)

5-2

create table test5_02(
  letter varchar(4),
  frequency numeric(4)
)
insert into test5_02(
  select letter,count(*)
  from(
    (
      select substr(name,2,1) letter
      from pub.student
    )
    union all
    (
    select substr(name,3,1) letter
    from pub.student
    where substr(name,3,1) is not null
    )
  )
  group by letter
)

5-3

create table test5_03
(
    dname varchar2(30),
    class varchar(10),
    p_count1 int,
    p_count2 int,
    p_count int
)
insert into test5_03(dname,class,p_count)(
  select dname,class,count(sid)
  from pub.student
  where dname is not null
  group by dname,class
)
update test5_03 t
  set p_count1=(
    select count(sid)
    from(
      select S.sid,S.dname,S.class
      from pub.student S,pub.course C,(
            SELECT sid, cid, MAX(score) AS max_score
            FROM pub.student_course
            GROUP BY sid, cid
        ) SC
      where S.sid = SC.sid and C.cid=SC.cid and SC.max_score >= 60
      group by S.sid,S.dname,S.class
      having sum(C.credit)>=10
    )a
    where t.dname=a.dname
    and t.class=a.class
  )
update test5_03 t
  set p_count2=(
    select count(sid)
    from(
      (
        select S.dname,S.class,S.sid
        from pub.student S,pub.course C,(
            SELECT sid, cid, MAX(score) AS max_score
            FROM pub.student_course
            GROUP BY sid, cid
        ) SC
        where SC.sid=S.sid
        and SC.cid=C.cid
        and SC.max_score>=60
        group by S.dname,S.class,S.sid
        having sum(C.credit)<10
      ) 
    union
      (
        select dname,class,sid
        from pub.student
        where sid not in(
            select sid
            from pub.student_course
          )
      )
    )a
    where t.dname=a.dname
    and t.class=a.class
  )

5-4

create table test5_04 
(
    dname varchar2(30),
    class varchar(10),
    p_count1 int,
    p_count2 int,
    p_count int
)
update test5_04 t set p_count1 = 
(select count(sid)
from 
(
	(select S.sid,S.dname,S.class
	from pub.student S,pub.course C,(
            SELECT sid, cid, MAX(score) AS max_score
            FROM pub.student_course
            GROUP BY sid, cid
        ) SC
	where S.sid = SC.sid and C.cid=SC.cid and SC.max_score >= 60 and S.class > 2008
	group by S.sid,S.dname,S.class
	having sum(C.credit) >= 10) 
	union
    (select S.sid,S.dname,S.class
	from pub.student S,pub.course C,(
            SELECT sid, cid, MAX(score) AS max_score
            FROM pub.student_course
            GROUP BY sid, cid
        ) SC
	where S.sid = SC.sid and C.cid=SC.cid and SC.max_score >= 60 and S.class <= 2008
	group by S.sid,S.dname,S.class
	having sum(C.credit) >= 8)
) temp
where t.dname = temp.dname and t.class  = temp.class)
update test5_04 t set p_count2 = 
(
	select count(sid)
	from 
	(
		(select S.sid,S.dname,S.class
		from pub.student S,pub.course C,(
            SELECT sid, cid, MAX(score) AS max_score
            FROM pub.student_course
            GROUP BY sid, cid
        ) SC
		where S.sid = SC.sid and C.cid=SC.cid and SC.max_score >= 60 and S.class > 2008
		group by S.sid,S.dname,S.class
		having sum(C.credit) < 10) 
		union 
        (select S.sid,S.dname,S.class
		from pub.student S,pub.course C,(
            SELECT sid, cid, MAX(score) AS max_score
            FROM pub.student_course
            GROUP BY sid, cid
        ) SC
		where S.sid = SC.sid and C.cid=SC.cid and SC.max_score >= 60 and S.class <= 2008
		group by S.sid,S.dname,S.class
		having sum(C.credit) < 8) 
		union
		(
			select sid,dname,class 
			from pub.student 
			where sid 
			not in
			(
				select sid 
				from pub.student_course
			)
		)
) temp
where t.dname = temp.dname and t.class  = temp.class)

5-5

create view test5_05 as (
select *
from
  (
    select S.dname,round(avg(SC.max_score)) avg_ds_score
    from pub.student S,pub.course C,(
      select sid,cid,max(score) max_score
      from pub.student_course
      group by sid,cid
    )SC
    where S.sid=SC.sid and C.cid=SC.cid and C.name='数据结构' and S.dname is not null
    group by S.dname
  )
  natural full outer join
  (
    select S.dname,round(avg(SC.max_score)) avg_os_score
    from pub.student S,pub.course C,(
      select sid,cid,max(score) max_score
      from pub.student_course
      group by sid,cid
    )SC
    where S.sid=SC.sid and C.cid=SC.cid and C.name='操作系统' and S.dname is not null
    group by S.dname
  )
)

5-6

create view test5_06 as (
select *
from
  (
    select S.sid,S.name,S.dname,SC.max_score ds_score
    from pub.student S,pub.course C,(
          select sid,cid,max(score) max_score
          from pub.student_course
          group by sid,cid
        )SC
    where S.sid=SC.sid and C.cid=SC.cid and S.dname='计算机科学与技术学院' and C.name='数据结构' and S.sid in(
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='数据结构'
      )
      intersect
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='操作系统'
      )
    )
  )
  natural full outer join
  (
    select S.sid,S.name,S.dname,SC.max_score os_score
    from pub.student S,pub.course C,(
          select sid,cid,max(score) max_score
          from pub.student_course
          group by sid,cid
        )SC
    where S.sid=SC.sid and C.cid=SC.cid and S.dname='计算机科学与技术学院' and C.name='操作系统' and S.sid in(
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='数据结构'
      )
      intersect
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='操作系统'
      )
    )
  )
)

5-7

create view test5_07 as (
select *
from
  (
    select S.sid,S.name,S.dname,SC.max_score ds_score
    from pub.student S,pub.course C,(
          select sid,cid,max(score) max_score
          from pub.student_course
          group by sid,cid
        )SC
    where S.sid=SC.sid and C.cid=SC.cid and S.dname='计算机科学与技术学院' and C.name='数据结构' and S.sid in(
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='数据结构'
      )
      union
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='操作系统'
      )
    )
  )
  natural full outer join
  (
    select S.sid,S.name,S.dname,SC.max_score os_score
    from pub.student S,pub.course C,(
          select sid,cid,max(score) max_score
          from pub.student_course
          group by sid,cid
        )SC
    where S.sid=SC.sid and C.cid=SC.cid and S.dname='计算机科学与技术学院' and C.name='操作系统' and S.sid in(
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='数据结构'
      )
      union
      (
        select sid
        from pub.student_course SC,pub.course C
        where C.cid=SC.cid and C.name='操作系统'
      )
    )
  )
)

5-8

create view test5_08 as (
select *
from
  (
    select S.sid,S.name,S.dname,SC.max_score ds_score
    from pub.student S,pub.course C,(
          select sid,cid,max(score) max_score
          from pub.student_course
          group by sid,cid
        )SC
    where S.sid=SC.sid and C.cid=SC.cid and S.dname='计算机科学与技术学院' and C.name='数据结构' 
  )
  natural full outer join
  (
    select S.sid,S.name,S.dname,SC.max_score os_score
    from pub.student S,pub.course C,(
          select sid,cid,max(score) max_score
          from pub.student_course
          group by sid,cid
        )SC
    where S.sid=SC.sid and C.cid=SC.cid and S.dname='计算机科学与技术学院' and C.name='操作系统'
  )
  natural full outer join
  (
  select S.sid,S.name,S.dname
  from pub.student S
  where S.dname = '计算机科学与技术学院' and S.sid not in (select S.sid from pub.student S,pub.course C,pub.student_course SC where S.sid = SC.sid and C.cid = SC.cid and (C.name = '数据结构' or C.name = '操作系统'))
  ) 
)

5-9

create view test5_09 as
with temp as(
  select SC.sid,SC.score
  from pub.student_course SC
  where SC.score>=60
)
select temp.score,count(sid) count1,
  (select count(sid) from temp) count0,
  (round(count(sid)/(select count(sid) from temp),4)*100) percentage
from temp
group by score

5-10

create or replace view test5_10 as
with temp as (
  select score, sid, cid
  from pub.student_course
  where score >= 60 and score <= 149
)
select
  sc.cid,
  c.name as cname,
  to_char(trunc(sc.score, -1), 'fm000') || '-' || to_char(trunc(sc.score, -1) + 9, 'fm000') as score,
  count(*) as count1,
  (select count(*)
   from temp
   where temp.cid = sc.cid) as count0,
  (round(count(sid)/(select count(*)
   from temp
   where temp.cid = sc.cid),4)*100) as percentage
from
  pub.course c,
  temp sc
where
  c.cid = sc.cid
group by
  sc.cid,
  c.name,
  to_char(trunc(sc.score, -1), 'fm000') || '-' || to_char(trunc(sc.score, -1) + 9, 'fm000');

实验六 

6-1

create or replace view test6_01 as
select S.sid,S.name,S.dname
from pub.student S
where S.age<20 and
S.dname='物理学院'
order by S.sid

6-2

create or replace view test6_02 as
select S.sid,S.name,sum(SC.score) sum_score
from pub.student S left outer join pub.student_course SC
on S.sid=SC.sid
where S.dname='软件学院' and
  S.class=2009
group by S.sid,S.name

6-3

create or replace view test6_03 as
select*
from
(
  select C.cid,C.name,max(SC.max_score) max_score
  from pub.course C left outer join 
    (select sid,cid,max(score) max_score
     from pub.student_course
     group by sid,cid
    )SC
  on C.cid=SC.cid
  group by C.cid,C.name
) 
natural full outer join
(
  select SC.cid,count(sid) max_score_count
  from (select sid,cid,max(score) max_score
     from pub.student_course
     group by sid,cid
    )SC
  group by SC.cid,SC.max_score
  having (SC.max_score=(select max(score) 
                   from pub.student_course temp
                   where SC.cid=temp.cid)
    )
)

6-4

create or replace view test6_04 as
select SC.sid,S.name
from pub.student_course SC,pub.student S,pub.course C
where SC.sid=S.sid and SC.cid=C.cid
and SC.score>=60 and (C.name='操作系统' or C.name='数据结构')
and S.sex='男' and (SC.sid not in(
  select SC.sid
  from pub.student_course SC,pub.course C
  where SC.cid=C.cid and
  C.name='程序设计语言' and
  SC.score>=60)
  )

6-5

create or replace view test6_05 as
select S.sid sid,S.name name,round(avg(score),0) avg_score,round(sum(score),0) sum_score
from pub.student S,pub.student_course SC
where S.sid=SC.sid and S.age=20
group by S.sid,S.name

6-6

create or replace view test6_06 as
select S.sid,S.name
from pub.student S,pub.student_course SC
where S.sid=SC.sid and
SC.score<60
group by S.sid,S.name,SC.cid
having (count(*)>=2)

6-7

create or replace view test6_07 as
select distinct S.sid,S.name
from pub.student S,pub.student_course SC
where S.sid=SC.sid and S.sid in(
  select sid
  from pub.student_course SC
  where not exists(
    select cid
    from pub.course C
    minus
    select cid
    from pub.student_course Temp
    where Temp.sid=SC.sid
  )
) and S.sid not in(
  select sid
  from pub.student_course SC
  where SC.score<60
)

6-8

create or replace view test6_08 as
with T as(
    select sid, cid, MAX(score) AS max_score
    from pub.student_course
    group by sid, cid
) 
select distinct S.sid,S.name
from pub.student S,T SC
where S.sid=SC.sid and S.sid in(
  select sid
  from T SC
  where not exists(
    select cid
    from pub.course C
    minus
    select cid
    from T Temp
    where Temp.sid=SC.sid
  )
) and S.sid not in(
  select sid
  from T SC
  where SC.max_score<60
)

6-9

create or replace view test6_09 as
select S.sid,S.name,sum(C.credit) sum_credit
from pub.student_course SC,pub.student S,pub.course C
where SC.cid=C.cid and SC.sid=S.sid
and S.dname='化学与化工学院'
and S.class=2010 and SC.score>=60
group by S.sid,S.name

6-10

create or replace view test6_10 as
select substr(S.name,1,1) second_name,count(*) p_count
from pub.student S
group by substr(S.name,1,1)

 实验七

7-1

create table test7_01 as
select S.sid, S.name, S.birthday
from pub.student S
create index test7_01_index  on test7_01 (substr(name,1,1))

7-2

create table test7_02 as
select sid,name,birthday from pub.student;
update test7_02
set birthday=to_date('19881018','yyyymmdd')
where substr(sid,12,1)='0'
create index test7_02_index on test7_02 (birthday,name)

7-3

create view test7_03 as 
select * from
(select sid,name,birthday,
(select count(*) from pub.student
where name like substr(t1.name,1,1)||'%'
) samefirstname 
from pub.student_testindex t1)   
where samefirstname=7

7-4

create view test7_04 as
select * from 
(select sid,name,birthday,
  (select count(*) from pub.student
   where birthday >= trunc(t1.birthday,'mm') and birthday <=last_day(t1.birthday)
  ) sameyearmonth,
  (select count(*) from pub.student 
   where birthday >= trunc(t1.birthday,'YYYY') and birthday <= last_day(add_months(trunc(t1.birthday,'yyyy'),11))
  ) sameyear
from pub.student_testindex t1
) 
where sameyearmonth=35

7-5

create view test7_05 as 
select * from 
(select sid,name,birthday,
(select count(*) from pub.student 
  
where birthday=t1.birthday+1
  
) nextbirthday
from pub.student_testindex t1) where nextbirthday=7

实验八 

create table test8_10(
  test varchar(20),
  age numeric(3)
)
insert all 
  into test8_10 values ('结果1', 88)
  into test8_10 values ('结果2', 90)
  into test8_10 values ('结果3', 90)
  into test8_10 values ('结果4', 86)
  into test8_10 values ('结果5', 90)
  into test8_10 values ('结果6', 90)
  into test8_10 values ('结果7', 86)
  into test8_10 values ('结果8', 86)
  into test8_10 values ('结果9', 76)
  into test8_10 values ('结果10', 86)
select * from dual

实验九 

9-1

create table test9_01(
sid char(12) not null ,
name varchar2(10) not null,
sex char(2), 
age int, 
birthday date,
dname varchar2(30), 
class varchar2(10) 
);
create index suoyin on test9_01(sid)
insert into test9_01(
  select *
  from pub.student
  where sex='女'
)
insert into test9_01(
  select *
  from pub.student_11_1
  where sex='女' and sid not in(
    select distinct sid
    from pub.student
    where sex='女'
  )
)
insert into test9_01(
  select *
  from pub.student_11_2
  where sex='女' and sid not in(
    select distinct sid
    from test9_01
  )
)

9-2

create table test9_02(
sid char(12) not null ,
name varchar2(10) not null,
sex char(2), 
age int, 
birthday date,
dname varchar2(30), 
class varchar2(10) 
);
create index suoyin1 on test9_02(sid)
insert into test9_02
(
select * from pub.student 
where  sex='女' and
sid in (select distinct sid from pub.student_course where score<60)
);
insert into test9_02
(
select * from pub.student_11_1 
where  sex='女' 
and sid not in (select distinct sid from test9_02)
and sid in (select distinct sid from pub.student_course where score<60)
);
insert into test9_02
(
select * from pub.student_11_2 
where  sex='女' 
and  sid not in (select distinct sid from test9_02)
and sid in (select distinct sid from pub.student_course where score<60)
);

更详细题目讲解

数据库SQL语言实战(二)-CSDN博客

数据库SQL语言实战(三)-CSDN博客

数据库SQL语言实战(四)(数据库系统概念第三章练习题)-CSDN博客

数据库SQL语言实战(五)(数据库系统概念第三章练习题)_数据库系统概括第三章sql语句数据练习-CSDN博客

 数据库SQL语言实战(六)-CSDN博客

数据库SQL语言实战(七)-CSDN博客

数据库SQL语言实战(八)-CSDN博客

数据库SQL语言实战(九)(索引)-CSDN博客

数据库SQL语言实战(十)(最后一篇)-CSDN博客

1、基本对应实验,从实验二开始 

2、中间有几篇是老师布置的作业题

 

 总结 

本文的所有题目均来自《数据库系统概念》(黑宝书)、山东大学数据库实验一到九。不可用于商业用途转发。

如果能帮助到大家,大家可以点点赞、收收藏呀~ 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/646541.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

代码随想录算法训练营第三十六天 | 1005.K次取反后最大化的数组和、134.加油站、135.分发糖果

目录 1005.K次取反后最大化的数组和 思路 代码 代码 134.加油站 思路 代码 135.分发糖果 思路 代码 1005.K次取反后最大化的数组和 本题简单一些&#xff0c;估计大家不用想着贪心 &#xff0c;用自己直觉也会有思路。 代码随想录 思路 直觉&#xff0c;直接写&…

<学习笔记>从零开始自学Python-之-实用库篇(一)-pyscript

由Anaconda创建的PyScript是一项实验性的但很有前途的新技术&#xff0c;它使python运转时在支撑WebAssembly的浏览器中作为一种脚本言语运用。 每个现代常用的浏览器现在都支撑WebAssembly&#xff0c;这是许多言语&#xff08;如C、C和Rust&#xff09;能够编译的高速运转时…

K8S/ hpa分享

在 Kubernetes 中&#xff0c;HorizontalPodAutoscaler 自动更新工作负载资源 &#xff08;例如 Deployment 或者 StatefulSet&#xff09;&#xff0c; 目的是自动扩缩工作负载以满足需求。 hpa的使用本身还是很简单的 示例如下&#xff1a; 官网示例 apiVersion: apps/v1 k…

基础—SQL—DDL—建表、查表、修改表以及总结

一、DDL—表—创建表与数据类型的设定 &#xff08;1&#xff09;要求 根据需求创建表(设计合理的数据类型、长度) 设计一张员工信息表&#xff0c;要求如下: 1、编号&#xff08;纯数字) 2、员工工号(字符串类型&#xff0c;长度不超过10位) 3、员工姓名&#xff08;字符串类…

设计模式10——装饰模式

写文章的初心主要是用来帮助自己快速的回忆这个模式该怎么用&#xff0c;主要是下面的UML图可以起到大作用&#xff0c;在你学习过一遍以后可能会遗忘&#xff0c;忘记了不要紧&#xff0c;只要看一眼UML图就能想起来了。同时也请大家多多指教。 装饰模式 是一种行为型模式。…

笔记88:LeetCode_134_加油站

前言&#xff1a; 前言1&#xff1a;这个题的题目条件给的不太严谨&#xff0c;题目描述中说“如果存在解&#xff0c;则保证它是唯一的”&#xff0c;通过我的实践&#xff0c;我发现这句话的意思其实是本题的所有样例只有两种情况&#xff0c;无解/有唯一解&#xff1b;而不可…

【Spring】认识 Spring AOP

认识 Spring AOP 1.什么是 AOP2.AOP 中的概念3.用 AOP 方式管理日志3.1 编写 AOP 日志注解类3.2 编写控制器用于测试 1.什么是 AOP AOP&#xff08;Aspect Oriented Program&#xff0c;面向切面编程&#xff09;把业务功能分为核心、非核心两部分。 核心业务功能&#xff1a…

tcpdump源码分析

进入tcpdump.c&#xff08;函数入口&#xff09;之前&#xff0c;先看一些头文件netdissect.h里定义了一个数据结构struct netdissect_options来描述tcdpump支持的所有参数动作&#xff0c;每一个参数有对应的flag, 在tcpdump 的main 里面&#xff0c; 会根据用户的传入的参数来…

构建高效的在线培训机构CRM应用架构实践

在当今数字化时代&#xff0c;在线培训已成为教育行业的重要趋势之一。为了提供更好的学习体验和管理服务&#xff0c;在线培训机构需要构建高效的CRM&#xff08;Customer Relationship Management&#xff09;应用架构。本文将探讨在线培训机构CRM应用架构的设计与实践。 一、…

力扣周赛398题解

特殊数组Ⅰ 如果数组的每一对相邻元素都是两个奇偶性不同的数字&#xff0c;则该数组被认为是一个 特殊数组 。 Aging 有一个整数数组 nums。如果 nums 是一个 特殊数组 &#xff0c;返回 true&#xff0c;否则返回 false。 示例 1&#xff1a; 输入&#xff1a;nums [1] …

数据结构和算法|排序算法系列(二)|冒泡排序

首先需要你对排序算法的评价维度和一个理想排序算法应该是什么样的有一个基本的认知&#xff1a; 《Hello算法之排序算法》 主要内容来自&#xff1a;Hello算法11.3 冒泡排序 我觉得冒泡排序非常有意思&#xff0c;也非常简单&#xff0c;就是不停地交换相邻的元素即可&#…

代码随想录算法训练营第四天| 24. 两两交换链表中的节点、19.删除链表的倒数第N个节点 、 面试题 02.07. 链表相交、142.环形链表II

24. 两两交换链表中的节点 题目链接&#xff1a; 24. 两两交换链表中的节点 文档讲解&#xff1a;代码随想录 状态&#xff1a;没做出来&#xff0c;没有正确更新头节点&#xff0c;因为head和cur共享引用&#xff0c;会随着cur的移动&#xff0c;丢失之前存放的节点 错误代码&…

腾讯发布ELLA:为扩散模型注入LLM能力,提升复杂场景的图像生成,准确率超90%

前言 近年来&#xff0c;基于扩散模型的文本到图像生成技术取得了显著进步&#xff0c;能够生成高质量、逼真的图像。然而&#xff0c;大多数扩散模型仍然使用CLIP作为文本编码器&#xff0c;这限制了它们理解复杂提示的能力&#xff0c;例如包含多个物体、详细属性、复杂关系…

摄像头应用测试

作者简介&#xff1a; 一个平凡而乐于分享的小比特&#xff0c;中南民族大学通信工程专业研究生在读&#xff0c;研究方向无线联邦学习 擅长领域&#xff1a;驱动开发&#xff0c;嵌入式软件开发&#xff0c;BSP开发 作者主页&#xff1a;一个平凡而乐于分享的小比特的个人主页…

MySQL(一) 库和表的基础操作

1. 数据库基础 1.1 什么是数据库 存储数据用文件就可以了&#xff0c;为什么还要弄个数据库? 文件保存数据有以下几个缺点&#xff1a; 文件的安全性问题文件不利于数据查询和管理文件不利于存储海量数据文件在程序中控制不方便 数据库存储介质&#xff1a;磁盘内存 为了解…

学 C/C++ 具体能干什么?

学习 C 和 C 后&#xff0c;你可以从事许多不同的工作和项目&#xff0c;这两种语言以其高性能和低级控制而闻名&#xff0c;特别适合以下几个领域&#xff1a; 1. 系统编程 C 和 C 是系统编程的首选语言&#xff0c;适用于操作系统、驱动程序和嵌入式系统开发。 操作系统开发…

PgMP:项目集管理,哪些人适合学习?

美国项目管理协会&#xff08;PMI&#xff09;对项目集经理&#xff08;Program Manager&#xff09;的角色做出如下的定义&#xff1a; 在最少的领导/监督下&#xff0c;项目集经理PgMP负责在商业和组织目的下协调管理多个相关项目。这些项目含有跨部门、组织、地理区域…

【kubernetes】探索k8s集群中金丝雀发布后续 + 声明式资源管理yaml

目录 一、K8S常见的发布方式 1.1蓝绿发布 1.2灰度发布&#xff08;金丝雀发布&#xff09; 1.3滚动发布 二、金丝雀发布 三、声明式管理方法 3.1YAML 语法格式 3.1.1查看 api 资源版本标签 3.1.2查看资源简写 3.2YAML文件详解 3.2.1Deployment.yaml 3.2.2Pod.yaml …

国际版Tiktok抖音运营流量实战班:账号定位/作品发布/热门推送/等等-13节

课程目录 1-tiktok账号定位 1.mp4 2-tiktok作品发布技巧 1.mp4 3-tiktok数据功能如何开通 1.mp4 4-tiktok热门视频推送机制 1.mp4 5-如何发现热门视频 1.mp4 6-如何发现热门音乐 1.mp4 7-如何寻找热门标签 1.mp4 8-如何寻找垂直热门视频 1.mp4 9-如何发现热门挑战赛 1…

【C语言回顾】编译和链接

前言1. 编译2. 链接结语 上期回顾: 【C语言回顾】文件操作 个人主页&#xff1a;C_GUIQU 归属专栏&#xff1a;【C语言学习】 前言 各位小伙伴大家好&#xff01;上期小编给大家讲解了C语言中的文件操作&#xff0c;接下来我们讲解一下编译和链接&#xff01; 1. 编译 预处理…