@3013216027
2016-01-28T13:19:08.000000Z
字数 1690
阅读 1019
数据库原理复习专栏
create index idx1 on tab(col)
或alter table tab add index on (col)
insert into tab2
是打错了?41. CD
42. B
43. BC
44. BD
45. B
46. BD
47. B
48. AB
49. BC
50. D
select sname from Sailors natural join Reserves natural join Boats where color = 'green' or color = 'red';
select rating from Sailors group by rating having avg(age) <= all (select avg(age) from Sailors group by rating);
或select rating from (select rating, avg(age) as avg_age from Sailors group by rating) as gps where avg_age = (select min(avg_age) from gps);
select sname from Sailors
where not exists (
select * from Boats
where color = 'red' and not exists (
select * from Reserves
where Reserves.bid = Boats.bid and Reserves.sid = Sailors.sid
));
create table work_in (
ssn char(10) not null,
did char(5) not null,
from date not null,
to date not null,
constraint pk_work_in primary key (ssn, did, from);
constraint fk_work_in_employees foreign key (ssn) references employees (ssn),
constraint fk_work_in_departments foreign key (did) references departments (did)
);
create assertion ast check (
(select count(ssn) from employees) = (select count(distinct ssn) from work_in)
and
(select count(did) from departments) = (select count(distinct did) from work_in)
);