pecifies the name of a table in which to hold statistics, and it is assumed that it resides in the same schema as the object for which statistics are collected (unless the statown parameter is specified). Users may create multiple tables with different stattabidentifiers to hold separate sets of statistics.stattab参数规定了保存统计信息的表明,通常情况下,如果没有指定statown参数,oracle以被统计对象所在的模式用户为stattab的拥有者。我们可以使用不同的stattab来分别存储不同的统计信息。
Additionally, users can maintain different sets of statistics within a single stattab by using the statid parameter, which can help avoid cluttering the user's schema.
灵位,我们也可以指定statid参数,从而在相同的stattab中存储不同的统计信息,这样可以使用户模式显得井井有条。
For all of the SET or GET procedures, if stattab is not provided (i.e., NULL), then the operation works directly on the dictionary statistics; therefore, users do not need to create these statistics tables if they only plan to modify the dictionary directly. However, if stattab is not NULL, then the SET or GET operation works on the specified user statistics table, and not the dictionary.
对于所有的set和get过程,如果我们没有指定stattab,oracle会将统计信息写入数据字典,如果指定了stattab,orcle只会将统计信息写入用户自定义表,而不会更新数据字典。
Create Stats Table
DBMS_STATS.CREATE_STAT_TABLE (
ownname VARCHAR2,
stattab VARCHAR2,
tblspace VARCHAR2 DEFAULT NULL);
ownname : Name of the schema.
stattab : Name of the table to create. This value should be passed as the stattab parameter to other procedures when the user does not want to modify the dictionary statistics directly. tblspace : Tablespace in which to create the stat tables. If none is specified, then they are created in the user's default tablespace.
Drop Stats Table
DBMS_STATS.drop_stat_table (
ownname VARCHAR2,
stattab VARCHAR2);
ownname : Name of the schema.
stattab : User stat table identifier.
Gather Schema Stats (本人在测试过程中,即便指定了stattab,该过程依然更新了数据字典)
DBMS_STATS.gather_schema_stats (
ownname VARCHAR2,
estimate_percent NUMBER DEFAULT NULL,
block_sample BOOLEAN DEFAULT FALSE,
method_opt VARCHAR2 DEFAULT 'FOR ALL COLUMNS SIZE 1',(size 1 指在该列上不创建histogram,如果该值大于1,则创建histogram)
degree NUMBER DEFAULT NULL,
granularity VARCHAR2 DEFAULT 'DEFAULT',
cascade BOOLEAN DEFAULT FALSE,
stattab VARCHAR2 DEFAULT NULL,
statid VARCHAR2 DEFAULT NULL,
options VARCHAR2 DEFAULT 'GATHER',
objlist OUT ObjectTab,
statown VARCHAR2 DEFAULT NULL);
ownname : Schema to analyze (NULL means current schema).
estimate_percent : Percentage of rows to estimate (NULL means compute): The valid range is [0.000001,100).
block_sample : Whether or not to use random block sampling instead of random row sampling. Random block sampling is more efficient, but if the data is not randomly distributed on disk, then the sample values may be somewhat correlated. Only pertinent when doing an estimate statistics.
method_opt : Method options of the following format (the phrase 'SIZE 1' is required to ensure gathering statistics in parallel and for use with the phrase hidden):
FOR ALL [INDEXED | HIDDEN] COLUMNS [SIZE integer]
This value is passed to all of the individual tables.
degree : Degree of parallelism (NULL means use table default value).
granularity : Granularity of statistics to collect (only pertinent if the table is partitioned).
DEFAULT: Gather global- and partition-level statistics.SUBPARTITION: Gather subpartition-level statistics.PARTITION: Gather partition-level statistics.GLOBAL: Gather global statistics.ALL: Gather all (subpartition, parti