相关链接
Deletes table-related statistics
删除表相关的统计信息
This procedure deletes table-related statistics.
这个过程会删除与表相关的统计数据。
The DBMS_STATS
package uses the constants shown in Table 142-1:
Table 142-1 DBMS_STATS Constants
Name 名称 |
Type 类型 |
Value 值 |
Description 描述 |
---|---|---|---|
AUTO_CASCADE | BOOLEAN | NULL | Lets Oracle decide whether to collect statistics for indexes or not 让Oracle决定是否收集索引的统计信息 |
AUTO_DEGREE | NUMBER | 32768 | Lets Oracle select the degree of parallelism based on size of the object, number of CPUs and initialization parameters. For definition of default parallel degree, see “Degree of Parallelism” in Oracle Database VLDB and Partitioning Guide. 让Oracle根据对象的大小、cpu的数量和初始化参数选择并行度。有关默认并行度的定义,请参阅Oracle数据库VLDB和分区指南中的"并行度"。 |
AUTO_INVALIDATE | BOOLEAN | NULL | Lets Oracle decide when to invalidate dependent cursors 让Oracle决定何时使依赖游标失效 |
AUTO_SIMPLESIZE | NUMBER | 0 | Indicates that auto-sample size algorithms should be used 表示自动样本大小应该使用的算法 |
参数有default值:可以不传参,使用默认值
参数无default值:必须传参才可调用
DBMS_STATS.DELETE_TABLE_STATS (
ownname VARCHAR2,
tabname VARCHAR2,
partname VARCHAR2 DEFAULT NULL,
stattab VARCHAR2 DEFAULT NULL,
statid VARCHAR2 DEFAULT NULL,
cascade_parts BOOLEAN DEFAULT TRUE,
cascade_columns BOOLEAN DEFAULT TRUE,
cascade_indexes BOOLEAN DEFAULT TRUE,
statown VARCHAR2 DEFAULT NULL,
no_invalidate BOOLEAN DEFAULT to_no_invalidate_type (
get_param('NO_INVALIDATE')),
force BOOLEAN DEFAULT FALSE);
1.如果是命令窗口就用exec 存储过程名,举个例子:
EXEC procedure;--procedure是存储过程名
2.如果是PL/SQL窗口就用 begin 存储过程名 end; 举个例子:
begin
procedure;--procedure是存储过程名
end;
3.如果是程序中调用就用 call 存储过程名 ,举个例子:
hibernateDao.excuteSqlUpdate("{Call proc_stuInfo()}");//存储过程proc_stuInfo
declare
-- Boolean parameters are translated from/to integers:
-- 0/1/null <--> false/true/null
cascade_parts boolean := sys.diutil.int_to_bool(:cascade_parts);
cascade_columns boolean := sys.diutil.int_to_bool(:cascade_columns);
cascade_indexes boolean := sys.diutil.int_to_bool(:cascade_indexes);
no_invalidate boolean := sys.diutil.int_to_bool(:no_invalidate);
force boolean := sys.diutil.int_to_bool(:force);
begin
-- Call the procedure
sys.dbms_stats.delete_table_stats(ownname => :ownname,
tabname => :tabname,
partname => :partname,
stattab => :stattab,
statid => :statid,
cascade_parts => cascade_parts,
cascade_columns => cascade_columns,
cascade_indexes => cascade_indexes,
statown => :statown,
no_invalidate => no_invalidate,
force => force);
end;
Table 142-21 DELETE_TABLE_STATS Procedure Parameters
Ser 序号 |
Parameter 参数名称 |
Type 类型 |
Default | IN / OUT | Note 参数说明 |
Range 取值范围 |
---|---|---|---|---|---|---|
1 | ownname | VARCHAR2 | IN | Name of the schema 方案名 |
[Any Schema] | |
2 | tabname | VARCHAR2 | IN | Name of the table to which this column belongs 列所在表的表名 |
[Any Table] | |
3 | partname | VARCHAR2 | Y | IN | Name of the table partition from which to get the statistics. If the table is partitioned and if partname is NULL , then the statistics are retrieved from the global table level.要删除统计信息的表分区名称。如果表是分区的,且 partname = NULL,则删除全局(global)级别列统计信息。 |
NULL default 如果表是分区的,且指定参数为NULL,则删除全局(global)级别的统计信息。 [Any table partition] |
4 | stattab | VARCHAR2 | Y | IN | User statistics table identifier describing from where to delete the statistics. If stattab is NULL , then the statistics are deleted directly from the dictionary.存储统计信息的目标表名。指定从哪个统计表(stattab)中删除统计信息,如果stattab为NULL,则从字典中删除统计信息。 |
NULLdefault 如果指定参数为NULL,则从字典中删除统计信息。 [Any Stattab] |
5 | statid | VARCHAR2 | Y | IN | Identifier (optional) to associate with these statistics within stattab (Only pertinent if stattab is not NULL ).statid表明stattab这个数据集的主键,可以理解为stattab的一个分区。statid只有在stattab参数不为NULL时才有效。 |
NULLdefault [Any Statid] |
6 | cascade_parts | BOOLEAN | Y | IN | If the table is partitioned and if partname is NULL , then setting this to TRUE causes the deletion of statistics for this table for all underlying partitions as well如果表是分区的,且 partname = NULL,那么cascade_parts为TRUE则表示同时删除该索引所有基础分区的统计信息。 |
TRUEdefault FALSE |
7 | cascade_columns | BOOLEAN | Y | IN | Indicates that DELETE_COLUMN_STATS should be called for all underlying columns (passing the cascade_parts parameter)表示应该为下面所有的列调用 DELETE_COLUMN_STATS 过程(传递 cascade_parts 参数) |
TRUEdefault FALSE |
8 | cascade_indexes | BOOLEAN | Y | IN | Indicates that DELETE_INDEX_STATS should be called for all underlying indexes (passing the cascade_parts parameter)表示应该为下面所有的索引调用 DELETE_COLUMN_STATS 过程(传递 cascade_parts 参数) |
TRUEdefault FALSE |
9 | statown | VARCHAR2 | Y | IN | Schema containing stattab (if different than ownname )statown表明stattab在哪个方案下,如果 statown = ownname,则可以不指定此参数。 |
NULLdefault [Any Schema] |
10 | no_invalidate | BOOLEAN | Y | IN | Does not invalidate the dependent cursors if set to TRUE . The procedure invalidates the dependent cursors immediately if set to FALSE . Use DBMS_STATS .AUTO_INVALIDATE . to have Oracle decide when to invalidate dependent cursors. This is the default. The default can be changed using the SET_DATABASE_PREFS Procedure, SET_GLOBAL_PREFS Procedure, SET_SCHEMA_PREFS Procedure and SET_TABLE_PREFS Procedure. |
DBMS_STATS.AUTO_INVALIDATEdefault 通过to_no_invalidate_type(get_param (‘NO_INVALIDATE’))获取,该值为Oralce常量。让Oracle决定何时使依赖游标失效。 TRUE 依赖游标有效。 FALSE 依赖游标失效。 |
11 | force | BOOLEAN | Y | IN | When value of this argument is TRUE , deletes index statistics even if locked当这个参数的值为TRUE时,即使锁表也会强制删除索引统计信息。 |
TRUE FALSE default |
Most of the DBMS_STATS procedures include the three parameters statown, stattab, and statid. These parameters allow you to store statistics in your own tables (outside of the dictionary), which does not affect the optimizer. Therefore, you can maintain and experiment with sets of statistics.
大多数DBMS_STATS过程包括三个参数statown、stattab和statid。这些参数允许您将统计信息存储在自己的表中(在字典之外),这不会影响优化器。因此,您可以维护和试验统计数据集。
The stattab parameter specifies 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). You can create multiple tables with different stattab identifiers to hold separate sets of statistics.
stattab参数指定用于保存统计信息的表的名称,并且假设它与为其收集统计信息的对象驻留在同一个方案(用户)中(除非指定了statown参数)。您可以使用不同的stattab标识符创建多个表,以保存不同的统计数据集。
The statown, stattab, and statid parameters instruct the package to back up current statistics in the specified table before gathering new statistics.
statown、stattab和statid参数指示包在收集新的统计信息之前备份指定表中的当前统计信息。
ORA-20000
: Object does not exist or insufficient privileges
对象不存在或权限不足
ORA-20002
: Bad user statistics table, may need to upgrade it
用户统计表坏了,可能需要升级它
ORA-20005
: Object statistics are locked
对象统计信息被锁定
To invoke this procedure you must be owner of the table, or you need the ANALYZE
ANY
privilege. For objects owned by SYS
, you need to be either the owner of the table, or you need the ANALYZE
ANY
DICTIONARY
privilege or the SYSDBA
privilege.
调用这个过程,你必须是表的所有者,或 ANALYZE ANY 权限。
对于SYS拥有的对象,你需要是表的所有者,或 ANALYZE ANY DICTIONARY 权限或 SYSDBA 权限。
20/09/30
M