Professional Documents
Culture Documents
Create Database Company
Create Database Company
use company
create table student
(
sid varchar(10) primary key,
name char(30) not null,
birthdate datetime not null,
sex char(6) default 'female'
check(sex
in('female','male')),
section char(6),
deptname char(40) not null,
)
answer for
all query
analyzer
questions
1. select
student.sid,name,grade from
student,G_report
where student.sid=G_report.sid
and grade='B'
2. select
student.sid,name,sex,course.cc
ode,ctitle,grade
from student,course,G_report
where student.sid=G_report.sid
and
course.ccode=G_report.ccode
and sex='female' and
ctitle='software' and
grade='A'
/*select
student.sid,name,sex,course.cc
ode,ctitle,grade
from student,course,G_report
where student.sid=G_report.sid
and
course.ccode=G_report.ccode
and sex='male' and
ctitle='software' and
grade='A'*/
3. select
student.sid,birthdate,section,
name,sex,deptname,grade from
student,G_report
where student.sid=G_report.sid
and deptname='cs' and
grade='A'
order by deptname desc,name
asc
4.
backup database company
to disk='c:\dba\company.bak'
5.
update student
set section='roo4'
where sid in(select sid from
G_report where
grade in('A','B') and
ccode='ict002')
6.
restore database company
from disk='c:\dba\company.bak'
7.
select
student.sid,name,sex,course.cc
ode,ctitle,grade
from student,course,G_report
where student.sid=G_report.sid
and
course.ccode=G_report.ccode
and grade between'A' and 'D'
and ctitle='calcules'
8.
select sid,name,deptname from
student
where deptname='cs' and name
like('%l%')