為Oracle數(shù)據(jù)表建立索引的一個簡單例子
當Oracle數(shù)據(jù)表的記錄較多的時候,為了提高查詢的效率,我們常常會為數(shù)據(jù)表建立索引,這樣在查詢的時候就能夠大大提高查詢的速度了。本文我們以一個實例的形式介紹了建立索引的過程,接下來就讓我們來一起了解一下這一過程。
首先,查看目前已經(jīng)建立的索引
- select index_name from all_indexes where table_name = ‘PICTURE’;
果然比較***,只有系統(tǒng)給主鍵自建的索引: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);
第三,再重復***步,驗證一下,是否成功。
第四, 感覺一下,瀏覽相冊時,速度是否快了一點。
因為理論上是應該快一點。
- 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)
關于為Oracle數(shù)據(jù)表建立索引的知識就介紹到這里了,希望通過本次的介紹能夠帶給您一些收獲,謝謝!
【編輯推薦】