【oracle】查询sql语句问题??高手请进

来源:百度知道 编辑:UC知道 时间:2024/09/22 03:51:06
1、基于哈西的索引和基于树的索引有何区别?
2、user表用于记录用户相关信息,photo表用于记录用户的照片信息:
create table user(
userId bigint; ------用户id
account varchar(30); ------用户账号
);

create table photo(
photoId bigint; ---------照片id
userId bigint; -----用户id
accessConut int; --------访问次数
size bigint; ------照片实际大小
);

1)请给出sql打印账号为“drag”的用户访问次数最多的5张照片的id
2)给出sql打印拥有照片总大小做多的前十名用户的id
3)为优化上边两个查询,需要在user 和photo表上建立什么样的索引?

2-1
select id from photo where id in (select id from (select id from photo where userid =(select userid from user where account = 'drag') order by accessConut)) where rownum < 6);

2-2
select id from(select id from photo group by id order by sum(size))
where rownum <11;

2-3
在id列上建索引分区索引(索引分类不是很懂,个人意见。。)