oracle创建索引

给oracle数据表建立索引
按照一般的说法,一个数据表如果数据量超过了几百条,就要考虑建立索引了。拖了这么久,今天终于给我们的一些变大了的数据表建立了索引。

首先,查看目前已经建立的索引
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)
posted @ 2010-06-25 22:31  你妹的sb  阅读(3980)  评论(0编辑  收藏  举报
百度一下