ITPub博客

首页 > 数据库 > Oracle > 重建DBMS_STATS解决ORA-31626 ORA-21633以及ORA-04063 ORA-06508 错误

重建DBMS_STATS解决ORA-31626 ORA-21633以及ORA-04063 ORA-06508 错误

原创 Oracle 作者:呱呱牛 时间:2016-10-11 20:52:43 0 删除 编辑
 在PL/SQL中无意间修改了package body-DBMS_STATS 的内容导致在系统多处功能异常。 如下

点击(此处)折叠或打开

  1. [oracle@mhxy01 ~]$ expdp scott/tiger directory=DMP dumpfile=emp.dump tables=emp
  2. Export: Release 11.2.0.4.0 - Production on Tue Oct 11 19:35:59 2016
  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
  4. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  5. With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
  6. Data Mining and Real Application Testing options
  7. ORA-31626: job does not exist
  8. ORA-31633: unable to create master table "SCOTT.SYS_EXPORT_TABLE_05"
  9. ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
  10. ORA-06512: at "SYS.KUPV$FT", line 1038
  11. ORA-01647: tablespace 'USERS' is read-only, cannot allocate space in it

点击(此处)折叠或打开

  1. SQL> exec dbms_stats.gather_table_stats(ownname => 'scott',tabname => 'emp');
  2. BEGIN dbms_stats.gather_table_stats(ownname => 'scott',tabname => 'emp'); END;
  3. *
  4. ERROR at line 1:
  5. ORA-04063: package body "SYS.DBMS_STATS" has errors
  6. ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_STATS"
  7. ORA-06512: at line 1
重建DBMS_STATS包,解决以上问题, 当然也有个ORA错误不是它引起来的,以下是重建过程
点击(此处)折叠或打开
  1. [oracle@mhxy01 ~]$ sqlplus / as sysdba
  2. SQL> set linesize 400
  3. SQL> select * from v$version;
  4. BANNER
  5. ----------------------------------------------------------------------------------------------------------------------------------------------------------------
  6. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  7. PL/SQL Release 11.2.0.4.0 - Production
  8. CORE 11.2.0.4.0 Production
  9. TNS for Linux: Version 11.2.0.4.0 - Production
  10. NLSRTL Version 11.2.0.4.0 - Production
  11. SQL> exec dbms_stats.gather_table_stats(ownname => 'scott',tabname => 'emp');
  12. BEGIN dbms_stats.gather_table_stats(ownname => 'scott',tabname => 'emp'); END;
  13. *
  14. ERROR at line 1:
  15. ORA-04063: package body "SYS.DBMS_STATS" has errors
  16. ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_STATS"
  17. ORA-06512: at line 1
  18. SQL> drop package DBMS_STATS;
  19. Package dropped.
  20. SQL> @?/rdbms/admin/dbmsstat.sql
  21. Package created.
  22. No errors.
  23. Synonym created.
  24. Grant succeeded.
  25. create role gather_system_statistics
  26. *
  27. ERROR at line 1:
  28. ORA-01921: role name 'GATHER_SYSTEM_STATISTICS' conflicts with another user or role name
  29. Grant succeeded.
  30. Grant succeeded.
  31. Library created.
  32. SQL> @?/rdbms/admin/prvtstas.plb
  33. Package created.
  34. No errors.
  35. SQL> @?/rdbms/admin/prvtstai.plb
  36. Package body created.
  37. No errors.
  38. SQL> @?/rdbms/admin/prvtstat.plb
  39. Package body created.
  40. No errors.
  41. SQL> exec dbms_stats.gather_table_stats(ownname => 'scott',tabname => 'emp');
  42. PL/SQL procedure successfully completed.
  43. SQL> exit
重建完成后再次执行 dbms_stats.gather_table_stats 是成功的
但是在 expdp的时候还是同样的错误提示,提示表空间USERS 是read only 状态,需要修改为online

点击(此处)折叠或打开

  1. [oracle@mhxy01 ~]$ expdp scott/tiger directory=DMP dumpfile=emp.dump tables=emp
  2. Export: Release 11.2.0.4.0 - Production on Tue Oct 11 19:35:59 2016
  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
  4. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  5. With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
  6. Data Mining and Real Application Testing options
  7. ORA-31626: job does not exist
  8. ORA-31633: unable to create master table "SCOTT.SYS_EXPORT_TABLE_05"
  9. ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
  10. ORA-06512: at "SYS.KUPV$FT", line 1038
  11. ORA-01647: tablespace 'USERS' is read-only, cannot allocate space in it
修改表空间USERS为online 

点击(此处)折叠或打开


  1. SQL> select name,file#,checkpoint_change# from v$datafile ;
  2. NAME                                                                                  FILE# CHECKPOINT_CHANGE#
    -------------------------------------------------------------------------------- ---------- ------------------
    +DATA/mhxy/datafile/system.256.922979845                                                  1            1678924
    +DATA/mhxy/datafile/sysaux.257.922979845                                                  2            1678924
    +DATA/mhxy/datafile/undotbs1.258.922979845                                                3            1678924
    +DATA/mhxy/datafile/users.259.922979847                                                   4            1387796
    +DATA/mhxy/datafile/example.264.922980153                                                 5            1678924
    +DATA/mhxy/datafile/undotbs2.265.922980651                                                6            1678924
  3. 6 rows selected
  4. SQL> alter system checkpoint;
  5. System altered
  6. SQL> select name,file#,checkpoint_change# from v$datafile;
  7. SQL> select name,file#,checkpoint_change# from v$datafile;
     
    NAME                                                                                  FILE# CHECKPOINT_CHANGE#
    -------------------------------------------------------------------------------- ---------- ------------------
    +DATA/mhxy/datafile/system.256.922979845                                                  1            1690156
    +DATA/mhxy/datafile/sysaux.257.922979845                                                  2            1690156
    +DATA/mhxy/datafile/undotbs1.258.922979845                                                3            1690156
    +DATA/mhxy/datafile/users.259.922979847                                                   4            1387796
    +DATA/mhxy/datafile/example.264.922980153                                                 5            1690156
    +DATA/mhxy/datafile/undotbs2.265.922980651                                                6            1690156
  8. 6 rows selected
  9. SQL> select tablespace_name,status from dba_tablespaces;
  10. TABLESPACE_NAME                STATUS
    ------------------------------ ---------
    SYSTEM                         ONLINE
    SYSAUX                         ONLINE
    UNDOTBS1                       ONLINE
    TEMP                           ONLINE
    USERS                          READ ONLY
    UNDOTBS2                       ONLINE
    EXAMPLE                        ONLINE
  11. 7 rows selected

  12. SQL> select checkpoint_change# from v$database;
  13. CHECKPOINT_CHANGE#
  14. ------------------
  15. 1690156
  16. SQL> alter tablespace users read write;
  17. Tablespace altered
  18. SQL> select tablespace_name,status from dba_tablespaces;
  19. TABLESPACE_NAME                STATUS
    ------------------------------ ---------
    SYSTEM                         ONLINE
    SYSAUX                         ONLINE
    UNDOTBS1                       ONLINE
    TEMP                           ONLINE
    USERS                          ONLINE
    UNDOTBS2                       ONLINE
    EXAMPLE                        ONLINE

  20. 7 rows selected
  21. SQL> select checkpoint_change# from v$database;
  22. CHECKPOINT_CHANGE#
  23. ------------------
  24. 1690156
  25. SQL> select checkpoint_change# from v$datafile;
  26. CHECKPOINT_CHANGE#
  27. ------------------
  28. 1690156
  29. 1690156
  30. 1690156
  31. 1690448
  32. 1690156
  33. 1690156
  34. 6 rows selected
  35. SQL> alter system checkpoint;
  36. System altered
  37. SQL> select checkpoint_change# from v$datafile;
  38. CHECKPOINT_CHANGE#
  39. ------------------
  40. 1690485
  41. 1690485
  42. 1690485
  43. 1690485
  44. 1690485
  45. 1690485
  46. 6 rows selected
  47. SQL>
再次expdp 正常导出数据备份

点击(此处)折叠或打开

  1. [oracle@mhxy01 ~]$ expdp scott/tiger directory=DMP dumpfile=emp.dump tables=emp
  2. Export: Release 11.2.0.4.0 - Production on Tue Oct 11 19:43:57 2016
  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
  4. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  5. With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
  6. Data Mining and Real Application Testing options
  7. Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** directory=DMP dumpfile=emp.dump tables=emp
  8. Estimate in progress using BLOCKS method...
  9. Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
  10. Total estimation using BLOCKS method: 64 KB
  11. Processing object type TABLE_EXPORT/TABLE/TABLE
  12. Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
  13. Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
  14. Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
  15. Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
  16. Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
  17. . . exported "SCOTT"."EMP" 8.562 KB 14 rows
  18. Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
  19. ******************************************************************************
  20. Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
  21. /oracledmp/emp.dump
  22. Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Tue Oct 11 19:44:29 2016 elapsed 0 00:00:22


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27039319/viewspace-2126134/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-05-29

  • 博文量
    96
  • 访问量
    286795