前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >oracle--索引

oracle--索引

作者头像
eadela
发布2019-09-29 16:07:49
3970
发布2019-09-29 16:07:49
举报
文章被收录于专栏:eadela

索引碎片整理实例

代码语言:javascript
复制
select * from user_indexes;

select * from user_ind_columns;

--建立表、索引:
create table t (id int);
create index ind_1 on t(id);
执行插入记录:
begin
  for i in 1..1000000 loop 
    insert into t values (i);
    if mod(i, 100)=0 then commit;
    end if;
  end loop;
end;
--分析索引:
analyze index ind_1 validate structure;
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
delete t where rownum<700000;
alter index ind_1 rebuild [online] [tablespace name];

--实例:
select count(*) from t;
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
analyze index ind_1 validate structure;
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
delete t where rownum < 700000;
commit;
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
analyze index ind_1 validate structure;
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
alter index ind_1 rebuild online ;--[tablespace name]
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
analyze index ind_1 validate structure;
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-09-21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档