[转] Oracle analyze 命令分析
2015-07-28 19:54
513 查看
转自:http://blog.sina.com.cn/s/blog_682841ba0101bncp.html
1.analyze table t1 compute statistics for table; -->user_tables
(只对表的总体信息进行统计,比如行数多少等,不涉及到表字段)
2.analyze table t2 compute statistics for all columns; -->user_tab_columns
(只会收集表字段信息)
3.analyze table t3 compute statistics for all indexed columns; -->user_tab_columns
(只会收集表中索引所在的字段信息)
4.analyze table t4 compute statistics for all indexes;à user_indexes
(只收集表索引的信息)
5.analyze table t5 compute statistics;
(收集表,表字段,索引的信息)
另外,可以删除分析数据:
SQL> analyze table my_table delete statistics;
SQL> analyze table my_table delete statistics for table for all indexes for all indexed columns;
例子:
create table t1 as select * from user_objects;
create table t2 as select * from user_objects;
create table t3 as select * from user_objects;
create table t4 as select * from user_objects;
create table t5 as select * from user_objects;
create table t6 as select * from user_objects;
create unique index pk_t1_idx on t1(object_id);
create unique index pk_t2_idx on t2(object_id);
create unique index pk_t3_idx on t3(object_id);
create unique index pk_t4_idx on t4(object_id);
create unique index pk_t5_idx on t5(object_id);
create unique index pk_t6_idx on t6(object_id);
<</B>刚建完表的时候>
(1) 查看表的统计信息
select table_name, num_rows, blocks, empty_blocks
from user_tables
where table_name in ('T1', 'T2', 'T3', 'T4', 'T5','T6');
(2) 查看字段的统计信息
select table_name,
column_name,
num_distinct,
low_value,
high_value,
density
from user_tab_columns
where table_name in ('T1', 'T2', 'T3', 'T4','T5','T6');
(3) 查看索引的统计信息
select table_name,
index_name,
blevel,
leaf_blocks,
distinct_keys,
avg_leaf_blocks_per_key avg_leaf_blocks,
avg_data_blocks_per_key avg_data_blocks,
clustering_factor,
num_rows
from user_indexes
where table_name in ('T1', 'T2', 'T3', 'T4', 'T5', 'T6');
二.执行analyze命令
analyze table t1 compute statistics for table; --针对表收集信息
analyze table t2 compute statistics for all columns; --针对表字段收集信息
analyze table t3 compute statistics for all indexes columns; --收集索引字段信息
analyze table t4 compute statistics; --收集表,表字段,索引信息
analyze table t5 compute statistics for all indexes; --收集索引信息
analyze table t6 compute statistics for table for all indexes for all columns; --收集表,索引,表字段信息
(1) 表的统计信息
select table_name, num_rows, blocks, empty_blocks
from user_tables
where table_name in ('T1', 'T2', 'T3', 'T4', 'T5','T6');
(2) 表中字段的统计信息
select table_name,
column_name,
num_distinct,
low_value,
high_value,
density
from user_tab_columns
where table_name in ('T1', 'T2', 'T3', 'T4','T5','T6');
<</B>其中会收集T2的表字段信息,T3是索引所在字段信息,T4表字段信息,T6表字段信息>
(3) 索引的统计信息
没有变化,说明在创建索引的时候就ORACLE就已经收集相关信息
1.analyze table t1 compute statistics for table; -->user_tables
(只对表的总体信息进行统计,比如行数多少等,不涉及到表字段)
2.analyze table t2 compute statistics for all columns; -->user_tab_columns
(只会收集表字段信息)
3.analyze table t3 compute statistics for all indexed columns; -->user_tab_columns
(只会收集表中索引所在的字段信息)
4.analyze table t4 compute statistics for all indexes;à user_indexes
(只收集表索引的信息)
5.analyze table t5 compute statistics;
(收集表,表字段,索引的信息)
另外,可以删除分析数据:
SQL> analyze table my_table delete statistics;
SQL> analyze table my_table delete statistics for table for all indexes for all indexed columns;
例子:
create table t1 as select * from user_objects;
create table t2 as select * from user_objects;
create table t3 as select * from user_objects;
create table t4 as select * from user_objects;
create table t5 as select * from user_objects;
create table t6 as select * from user_objects;
create unique index pk_t1_idx on t1(object_id);
create unique index pk_t2_idx on t2(object_id);
create unique index pk_t3_idx on t3(object_id);
create unique index pk_t4_idx on t4(object_id);
create unique index pk_t5_idx on t5(object_id);
create unique index pk_t6_idx on t6(object_id);
<</B>刚建完表的时候>
(1) 查看表的统计信息
select table_name, num_rows, blocks, empty_blocks
from user_tables
where table_name in ('T1', 'T2', 'T3', 'T4', 'T5','T6');
(2) 查看字段的统计信息
select table_name,
column_name,
num_distinct,
low_value,
high_value,
density
from user_tab_columns
where table_name in ('T1', 'T2', 'T3', 'T4','T5','T6');
(3) 查看索引的统计信息
select table_name,
index_name,
blevel,
leaf_blocks,
distinct_keys,
avg_leaf_blocks_per_key avg_leaf_blocks,
avg_data_blocks_per_key avg_data_blocks,
clustering_factor,
num_rows
from user_indexes
where table_name in ('T1', 'T2', 'T3', 'T4', 'T5', 'T6');
二.执行analyze命令
analyze table t1 compute statistics for table; --针对表收集信息
analyze table t2 compute statistics for all columns; --针对表字段收集信息
analyze table t3 compute statistics for all indexes columns; --收集索引字段信息
analyze table t4 compute statistics; --收集表,表字段,索引信息
analyze table t5 compute statistics for all indexes; --收集索引信息
analyze table t6 compute statistics for table for all indexes for all columns; --收集表,索引,表字段信息
(1) 表的统计信息
select table_name, num_rows, blocks, empty_blocks
from user_tables
where table_name in ('T1', 'T2', 'T3', 'T4', 'T5','T6');
(2) 表中字段的统计信息
select table_name,
column_name,
num_distinct,
low_value,
high_value,
density
from user_tab_columns
where table_name in ('T1', 'T2', 'T3', 'T4','T5','T6');
<</B>其中会收集T2的表字段信息,T3是索引所在字段信息,T4表字段信息,T6表字段信息>
(3) 索引的统计信息
没有变化,说明在创建索引的时候就ORACLE就已经收集相关信息
相关文章推荐
- 报错:System.Data”中不存在类型或命名空间名称“OracleClient
- 类型“System.Data.OracleClient.OracleParameter”在未被引用的程序集中定义。必须添加对程序集“System.Data.OracleClient, Version=
- Oracle 10g PL/SQL
- CentOs 6.3_64静默安装oracle11g_r2
- oracle印象之游标
- python cx_Oracle模块的安装和使用
- Oracle MapViewer11g安装与部署
- oracle 11 impdb expdb使用方法
- 转如何在oracle中导入dmp数据库文件
- Oracle RAC客户端tnsnames.ora相关配置及测试
- Oracle的in/not in(x,...,null)
- oracle坏块及解决办法
- Oracle到SAP HANA实时复制系列(一):初识SRS
- Oracle到SAP HANA实时复制系列(二):Replication Server的安装与配置
- oracle 12 安装报错
- Oracle到SAP HANA实时复制系列(三):Replication Agent的安装与配置
- Oracle入门学习----通过jdbc连接oracle实例
- Oracle 创建表空间与用户
- Oracle数据库再次安装
- 一次ORACLE启动报错修复的记录