达梦数据库、oracle数据库如何判断指定表有没有建立索引?对应的表有没有索引查询方法

sm_appmenuitem 这个演示表有 5 个索引。
我在不知道的情况下想知道这个表的索引有没有建成功,或者说我现在想知道这个表的索引有哪些,就要来查询了。
索引表查询方法如下,把对应的表放到括号里就能查出来了,达梦数据库和 oracle 数据库通用这个方法。

# 这两个方法都可以,属于全局级的表。
select * from user_indexes where table_name=upper('sm_appmenuitem'); 
select * from user_ind_columns where table_name = upper('sm_appmenuitem');

5 个索引相当于 5 的阶乘。现在查询时间 2 秒的话,如果没有索引,查询时间就是 25 次方秒 ≈ 32 秒,可见索引的重要性。
在这里插入图片描述
在这里插入图片描述
索引建表过程:

/* indexcode: i_sm_appmenuitem_1 */
create  index i_sm_appmenuitem_1 on sm_appmenuitem (pk_menuitem)
/

/* indexcode: i_sm_appmenuitem_2 */
create  index i_sm_appmenuitem_2 on sm_appmenuitem (menuitemcode)
/

/* indexcode: i_sm_appmenuitem_3 */
create  index i_sm_appmenuitem_3 on sm_appmenuitem (appid)
/

/* indexcode: i_sm_appmenuitem_4 */
create  index i_sm_appmenuitem_4 on sm_appmenuitem (appcode)
/

/* indexcode: i_sm_appmenuitem_5 */
create  index i_sm_appmenuitem_5 on sm_appmenuitem (menuitemname)
/

喜欢的点个赞❤吧!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章