1 SQL 语言中, SELECT 语句的执行结果是 b表
2数据库是指有组织地,动态地存储在(外存)上的相 互联系的数据的集合
3关系代数中专门的关系运算包括:选择、投影、联接。
4、 关系模型的数据结构是一个“二维表空间”组成的集合。
5、数据库管理系统中数据 *** 纵语言( DML )所实现的 *** 作一般包括Create(建立数据表)、Alter(更改数据表)、Drop(删除数据表)。
--1、利用SQL语句创建以上三张表,并指定每张表的主键和外键;
--学生表(S):
create table student
(
sid varchar2(20) primary key,
sname varchar2(20),
age number,
sex varchar2(4),
department varchar2(20),
address varchar2(50),
birthplace varchar2(50)
);
--选课表(SC):
create table class
(
sid varchar2(20) references student(sid),
cid varchar2(20) primary key,
grade number
);
--教师表(C):
create table teacher
(
cid varchar2(20) references class(cid),
cname varchar2(20),
teacher varchar2(20)
);
--2、以上三张表各插入一条记录,
--记录值分别为:(s20110101,王林,20,男,经济管理系,浙江省杭州市西湖区168号,浙--江杭州)、
--(s20110101,1001,85)、(1001,网络数据库与应用,李小波);
insert into student
values
('s20110101',
'王林',
20,
'男',
'经济管理系',
'浙江省杭州市西湖区168号',
'浙江杭州');
insert into class values ('s20110101', '1001', 85);
insert into teacher values ('1001', '网络数据库与应用', '李小波');
--3、查询李老师所教的课程号、课程名称;
select cid, cname from teacher where teacher like '李%';
--4、查询年龄在23岁26岁之间的女学生的学号和姓名;
select sid, sname
from student
where sex = '女'
and age >= 23
and age <= 26;
--5、查询“李小波”所选修的全部课程名称;
select tcname
from student s, class c, teacher t
where ssid = csid
and ccid = tcid
and asname = '李小波';
--6、查询所有成绩都在90分以上的学生姓名及所在系;
select ssname, sdepartment
from student s, class c
where ssid = csid
and cgrade > 90;
--7、查询没有选修“ *** 作系统”课的学生的姓名;
select ssname
from student s, class c, teacher t
where ssid = csid
and ccid = tcid
and tcname = ' *** 作系统';
--8、查询与“李小波”同乡的男生姓名及所在系;
select sname, department
from student
where sex = '男'
and address in (select address from student where sname = '李小波')
and sname <> '李小波';
--9、查询英语成绩比数学成绩好的学生;
select ssname
from student s
where ssid in (select c1sid
from (select csid, cgrade
from class c, reachar t
where ccid = tcid
and tname = '英语') c1,
class (select csid, cgrade
from class c, reachar t
where ccid = tcid
and tname = '数学') c2
where c1sid = c2sid
and c1grade > c2grade);
--10、查询选修同一门课程时,女生比男生成绩好的学生名单;
select fsname
from (select ssname, ccid, cgrade
from student s, class c
where ssid = csid
and ssex = '女') f,
(select ccid, cgrade
from student s, class c
where ssid = csid
and ssex = '男') m
where fcid = mcid
and fgrade > mgrade;
--11、查询至少选修两门以上课程的学生姓名、性别;
select ssname, ssex
from student s, class c, teachar t
where ssid = csid
group by ssname, ssex
having count(distinct ccid) > 2;
--12、查询选修了李老师所讲课程的学生人数;
select count(distinct ssid)
from student s, class c, teacher t
where ssid = csid
and ccid = tcid
and tteacher like '李%';
--13、查询没有选修李老师所讲课程的学生;
select ssname
from student s, class c
where ssid = csid
and ccid not in (select cid from teacher where teacher like '李%');
--14、查询“ *** 作系统”课程得最高分的学生姓名、性别、所在系;
select sname, sex, department
from student s, class c, teacher t
where ssid = csid ccid = tcid
and cname = ' *** 作系统'
and cgrade in (select max(grade)
from class c1, teacher t1
where c1cid = t1cid
and cname = ' *** 作系统');
全部手打,望采纳。。。
use master
go
if exists(select from sysdatabases where name='factory')
drop database factory
go
create database factory
go
use factory
go
create table depart
(
deid int primary key,
dename char(10)
)
create table worker
(
wid int primary key,
wname char(8),
wsex char(2) default('男'),
wbir datetime,
party bit,
worktime datetime,
deid int foreign key references depart(deid)
)
create table salary
(
wid int foreign key references worker(wid),
stime datetime,
salary dec(6,1) check(salary<=15000),
primary key(wid,stime)
)
1select wwid,wwname,avg(ssalary) avgsa from worker w left outer join salary s
on wwid=swid group by wwid,wwname
2select wwid,wwname,ddename from depart d right outer join worker w
on wdeid=ddeid
以上就是关于大学计算机关于数据库的作业,请高手帮忙。全部的内容,包括:大学计算机关于数据库的作业,请高手帮忙。、SQL网络数据库问题、数据库作业等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)