---
title: "表分析语句"
author: "hotjava"
date: "2008-04-10T17:13:16Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2008-04-10T17:13:16Z"
id: 181354
url: "https://hotjava.iteye.com/blog/181354"
---

Exec dbms_stats.gather_schema_stats(ownname=>'用户名称',estimate_percent=>100,cascade=> TRUE, degree =>12); 


    含义解释 ownname:填写需要分析的用户（该用户下所有表都将被分析）
              estimate_percent:分析抽样的力度
              cascade:是否对索引进行分析
              degree:并行处理的cpu数量

 对单个表做分析推荐使用 analyze table 表名 compute statistics;（将会把表下的索引一起分析） 对单个索引进行分析推荐使用 analyze index 索引名 compute statistics;



当然对单个表或者索引的分析也可以采用

        dbms_stats.gather_index_stats
dbms_stats.gather_table_stats
(exec dbms_stats.gather_table_stats(ownname=>'hbsps',tabname=>'fail_reason',estimate_percent=>100,cascade=> TRUE);
)