欢迎进入oracle社区论坛,与200万技术人员互动交流 >>进入
按照一般的说法,一个数据表如果数据量超过了几百条,就要考虑建立索引了。拖了这么久,今天终于给我们的一些变大了的数据表建立了索引。
首先,查看目前已经建立的索引
select index_name from all_indexes where table_name = 'picture';
果然比较弱智,只有系统给主键自建的索引:sys_c55001
还犯了一个错误,一般情况下,oracle是不管大小写的,但上面查询语句里面的table_name必须大写,如果写成'picture'则是没有记录。
接着,建立索引。
create index picture_album_idx on picture (aid);
create index picture_user_idx on picture (userid);
create index picture_cat_idx on picture (cid);
第三,再重复第一步,验证一下,是否成功。
第四, 感觉一下,浏览相册时,速度是否快了一点。
因为理论上是应该快一点。
-----------------------
eg:
select index_name from all_indexes where table_name = 'tb_put_approve';
select * from tb_put_approve t
create index tb_put_approve_approveid on tb_put_approve(approveid)
