oracle 重建执行计划时数据库表被锁定的解锁命令

当执行计划重建时,

exec dbms_stats.delete_table_stats('product','UP_PROD_ITEM_CATALOG');   --------删除执行计划

exec dbms_stats.delete_table_stats('product','UP_PRODUCT_ITEM');   --------删除执行计划

exec dbms_stats.delete_table_stats('product','UP_CATALOG_REGION');   --------删除执行计划

exec dbms_stats.delete_table_stats('product','UP_ITEM_REGION');   --------删除执行计划

exec dbms_stats.delete_table_stats('product','UP_ITEM_RELAT');   --------删除执行计划

exec dbms_stats.gather_table_stats('product','UP_PROD_ITEM_CATALOG',estimate_percent => 10,method_opt => 'for all columns size 1',degree => 8);    -------新增执行计划

--exec dbms_stats.gather_table_stats('product','UP_PRODUCT_ITEM',estimate_percent => 10,method_opt => 'for all columns size 1',degree => 8);    -------新增执行计划

exec dbms_stats.gather_table_stats('product','UP_CATALOG_REGION',estimate_percent => 10,method_opt => 'for all columns size 1',degree => 8);    -------新增执行计划

exec dbms_stats.gather_table_stats('product','UP_ITEM_REGION',estimate_percent => 10,method_opt => 'for all columns size 1',degree => 8);    -------新增执行计划

exec dbms_stats.gather_table_stats('product','UP_ITEM_RELAT',estimate_percent => 10,method_opt => 'for all columns size 1',degree => 8);    -------新增执行计划

comment on table  product.UP_PROD_ITEM_CATALOG is '';

comment on table  product.UP_PRODUCT_ITEM is '';

comment on table  product.UP_CATALOG_REGION is '';

comment on table  product.UP_ITEM_REGION is '';

comment on table  product.UP_ITEM_RELAT is '';

报错如下

ORA-20005: OBJECT STATISTICS ARE LOCKED (STATTYPE = ALL)。

然后从USER_TAB_STATISTICS中发现统计视图中STATTYPE=ALL了,默认情况中该字段为null,表示没有锁住信息。

运行DBMS_STATS.UNLOCK_TABLE_STATS来解锁表统计信息,就可以对表进行分析了。

exec dbms_stats.unlock_table_stats('product','UP_PRODUCT_ITEM');

posted @ 2013-01-30 09:01  kevinboy  阅读(606)  评论(0编辑  收藏  举报