周末无事水文章,期末备考的总结资料
select distinct dept_name
from instructor;
select all dept_name from instructor;
select A1, A2, ..., An
from r1, r2, ..., rm
where P;
select name, title
from instructor
natural join teaches natural join course;
select ID, name, salary/12 as monthly_salary
from instructor;
select distinct T. name
from instructor as T, instructor as S
where T.salary > S.salary and S.dept_name = 'Comp. Sci.';
select name
from instructor
where name like '%in%' ;
select distinct name
from instructor
order by name;
select course_id
from section
where semester = 'Fall' and year = 2009
union
select course_id
from section
where semester = 'Spring' and year = 2010;
select course_id
from section
where semester = 'Fall' and year = 2009
intersect
select course_id
from section
where semester = 'Spring' and year = 2010;
select course_id
from section
where semester = 'Fall' and year = 2009
except
select course_id
from section
where semester = 'Spring' and year = 2010;
select dept_name, avg (salary)
from instructor
group by dept_name;
select dept_name, avg (salary)
from instructor
group by dept_name
having avg (salary) > 42000;
select distinct course_id
from section
where semester = 'Fall' and year= 2009 and course_id in
(select course_id
from section
where semester = 'Spring' and year= 2010);
select name
from instructor
where salary > some
(select salary
rom instructor
where dept_name = 'Biology');
select course_id
from section as S
where semester = ’Fall’ and year = 2009 and
exists (select *
from section as T
where semester = ’Spring’ and year= 2010 and S.course_id = T.course_id);
select T.course_id
from course as T
where unique (select R.course_id
from section as R
where T.course_id= R.course_id
and R.year = 2009);
delete from r where P;
insert into course values ('CS-437', 'Database Systems', 'Comp. Sci.', 4);
insert into course (course_id, title, dept_name, credits)
values ('CS-437', 'Database Systems', 'Comp. Sci.', 4);
update instructor
set salary = salary * 1.03
where salary > 100000;