首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >达梦数据库、oracle数据库如何判断指定表有没有建立索引?对应的表有没有索引查询方法

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

作者头像
小蓝枣
发布于 2020-09-24 09:53:08
发布于 2020-09-24 09:53:08
3.7K0
举报

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

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

5 个索引相当于 5 的阶乘。现在查询时间 2 秒的话,如果没有索引,查询时间就是 2 的 5 次方秒 ≈ 32 秒,可见索引的重要性。

索引建表过程:

代码语言:javascript
复制
/* 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)
/
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/05/20 ,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档