概述
很多时候我们都需要对某些大表去建索引或者重建,如果不正当操作就很有可能会影响到生产环境,针对这个方面我写了一些关于数据库索引创建及索引重建变更的规范,仅供参考。
一、索引创建前检查
1、检查表段大小:
select segment_name, bytes/1024/1024 MB from user_segments where segment_name='';
![b710805aec3a86b1b5193e386858bdaa.png](https://i-blog.csdnimg.cn/blog_migrate/f38fb3f06b6d862ff89392396e69f5f6.jpeg)
2、检查表列不同值分布情况:
select a.table_name, a.column_name, a.num_distinct, round(a.num_distinct * 100 / b.num_rows) "distinct percent%" from user_tab_columns a, user_tables b where a.table_name = b.table_name and a.table_name = 'ORDER_RELEASE_STATUS';