Oracle Database Object invalid

Source: Internet
Author: User

VPD is used for development in the project. The creation of Database User B objects depends on user A. Because user A objects perform DDL, migration, dump, and other operations, this results in the INVALID of user B. User B is used as the data source of the application system, which leads to application system errors.

You can perform the following operations:

1. Find the invalid object

  1. SelectObject_type, object_id, object_name
  2. FromUser_objects
  3. WhereStatus ='Invalid' Order ByObject_type
2. After judgment, you can recompile these objects.

Compilation methods include:

1) DBMS_DDL

2.) DBMS_UTILITY
3.) UTL_RECOMP
4) UTLRP. SQL
5) Manually Recompile


The best solution is to manually compile these objects. You can refer to the following SQL script:

  1. Spool recompile. SQL
  2. Select'Alter'Object _ type' 'object _ name' compile ;'
  3. FromUser_objects
  4. WhereStatus <> 'valid'
  5. AndObject_typeIN('VIEW', 'Synonym ',
  6. 'PROCEDURE','FUNCTION',
  7. 'Package ','TRIGGER');
  8. SpoolOff
  9. @ Recompile. SQL
  10. Note:VIEW, SYNONYM,PROCEDURE, PACKAGE,FUNCTION,TRIGGER
  11. Spool pkg_body. SQL
  12. Select'AlterPackage 'object _ name' compile body ;'
  13. FromUser_objects
  14. WhereStatus <> 'valid'
  15. AndObject_type = 'package body ';
  16. SpoolOff
  17. @ Pkg_body. SQL
  18. Spool undefined. SQL
  19. Select'AlterMaterizlizedView'Object _ name' compile ;'
  20. FromUser_objects
  21. WhereStatus <> 'valid'
  22. AndObject_type = 'undefined ';
  23. SpoolOff
  24. @ Undefined. SQL
  25. Spool javaclass. SQL
  26. Select'AlterJava class 'object _ name' resolve ;'
  27. FromUser_objects
  28. WhereStatus <> 'valid'
  29. AndObject_type = 'java class ';
  30. SpoolOff
  31. @ Javaclass. SQL
  32. Spool typebody. SQL
  33. Select'AlterType 'object _ name' compile body ;'
  34. FromUser_objects
  35. WhereStatus <> 'valid'
  36. AndObject_type = 'Type body ';
  37. SpoolOff
  38. @ Typebody. SQL
  39. Spool public_synonym. SQL
  40. Select'Alter PublicSynonym 'object _ name' compile ;'
  41. FromUser_objects
  42. WhereStatus <> 'valid'
  43. AndOwner ='PUBLIC'
  44. AndObject_type = 'synonym ';
  45. SpoolOff
  46. @ Public_synonym. SQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.