1.分析表

begin

dbms_stats.gather_table_stats (

  ownname          => 'TEST',

  tabname          => 'STUDENT',

  estimate_percent => dbms_stats.AUTO_SAMPLE_SIZE,

  degree           => 4,

  cascade          => TRUE);

end;

2.分析用户

begin

dbms_stats.gather_schema_stats(

    ownname          => 'TEST',

    estimate_percent => dbms_stats.AUTO_SAMPLE_SIZE,

    degree           => 4,

    cascade          => TRUE);

end;

3.分析索引

begin

dbms_stats.gather_index_stats(

  ownname          => 'TEST',

  indname          => 'IDX_STUDENT_BIRTH',

  estimate_percent => dbms_stats.AUTO_SAMPLE_SIZE,

  degree           => 4);

end;

一般来说,ORACLE都会锁定统计信息,这是为了稳定执行计划。如果在进行表分析是发现表被锁住,需要进行解锁:

①按用户schema解锁:EXEC DBMS_STATS.UNLOCK_schema_STATS('user');

②按表模式解锁:先查出被锁定的表select table_name from user_tab_statistics where stattype_locked is not null;然后exec dbms_stats.unlock_table_stats(user,'表名');

 

相关文章:

  • 2021-11-04
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-07-10
  • 2021-06-11
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2021-11-17
  • 2021-07-04
  • 2021-08-17
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案