Issue:
After successfully upgrading an Oracle Database 19c environment, it is common to validate the database by checking for invalid objects and recompiling them. In some cases, administrators may encounter unexpected errors while recompiling invalid objects within a Pluggable Database (PDB).
A common scenario involves ORA-65047 and ORA-07445 [csyalt()+608] errors when attempting to compile invalid objects or while executing datapatch during post-patch SQL actions.
Problem Description
Following a successful Oracle 19c database upgrade or patching activity, one or more objects may remain in an INVALID state inside a PDB.
For example, a PUBLIC SYNONYM may appear as invalid.
When attempting to recompile the object using the standard SQL command:
ALTER <OBJECT_TYPE> <OBJECT_NAME> COMPILE;
the operation fails with errors similar to:
ORA-65047: Operation not allowed from within a pluggable database
ORA-07445: exception encountered: core dump [csyalt()+608]
The same behavior may also occur during the execution of datapatch, preventing post-patch SQL actions from completing successfully.
Root Cause
Certain metadata-linked objects, such as PUBLIC SYNONYMS, are managed at the container database (CDB) level and have restrictions when modified directly from within a PDB.
Although these objects are visible inside the PDB, Oracle does not allow standard DDL operations on them using regular SQL commands.
As a result, recompilation attempts fail with ORA-65047, and in some situations, an internal ORA-07445 error may also be reported.
When this issue will occur:
- Recompiling metadata-linked objects inside a PDB.
- Fixing invalid PUBLIC SYNONYMS after database upgrades.
- Addressing invalid objects that prevent datapatch from completing.
- Performing supported DDL operations on restricted Oracle-managed objects within a PDB.
Solution
Oracle provides a supported mechanism through the DBMS_PDB package that allows specific restricted DDL operations to be executed safely within a PDB.
The procedure to use is:
DBMS_PDB.EXEC_AS_ORACLE_SCRIPT
This API executes the supplied DDL statement as an Oracle internal script, bypassing the restrictions imposed on metadata-linked objects.
Example
If the invalid object is a PUBLIC SYNONYM, execute:
EXEC DBMS_PDB.EXEC_AS_ORACLE_SCRIPT(
‘CREATE OR REPLACE PUBLIC SYNONYM <PACKAGE_NAME> FOR SYS.<PACKAGE_NAME>’);
For example:
EXEC DBMS_PDB.EXEC_AS_ORACLE_SCRIPT(
‘CREATE OR REPLACE PUBLIC SYNONYM STANDARD FOR SYS.STANDARD’);
PL/SQL procedure successfully completed.
Why DBMS_PDB.EXEC_AS_ORACLE_SCRIPT works
DBMS_PDB.EXEC_AS_ORACLE_SCRIPT works because it tells Oracle to execute the supplied SQL statement as if it were an Oracle internal script, rather than as a normal user-issued command.
In a multitenant architecture (CDB/PDB), Oracle protects metadata-linked objects (such as PUBLIC SYNONYMS, Oracle-supplied packages, and other system metadata) from being modified directly within a PDB. When you execute a standard DDL statement like:
ALTER PUBLIC SYNONYM … COMPILE;
or
CREATE OR REPLACE PUBLIC SYNONYM …
Oracle checks whether the operation is permitted inside the PDB. Since these are Oracle-managed metadata objects, the operation is blocked and raises errors such as:
- ORA-65047: Operation not allowed from within a pluggable database
- ORA-07445 (in some affected cases)
Why it fixes the invalid object
After an upgrade or patch, some Oracle-managed objects may become invalid due to interrupted recompilation or metadata inconsistencies. Since a normal compile is restricted inside a PDB, the object remains invalid. Executing the DDL through DBMS_PDB.EXEC_AS_ORACLE_SCRIPT recreates or recompiles the object in Oracle’s internal context, restoring it to the VALID state.
Verify the status of object
SELECT owner,
object_name,
object_type,
status
FROM dba_objects
WHERE object_name = ‘PUBLIC’;
OWNER OBJECT_NAME OBJECT_TYPE STATUS
——– ————- ————– ——-
PUBLIC PUBLIC SYNONYM VALID
PUBLIC PUBLIC VIEW VALID
The invalid object is now successfully compiled.
Conclusion: –
Encountering ORA-65047 and ORA-07445 [csyalt()+608] during object recompilation or while running datapatch can be confusing, especially after a successful Oracle 19c upgrade. In many cases, the issue is caused by Oracle’s restrictions on metadata-linked objects within a Pluggable Database.
Using the DBMS_PDB.EXEC_AS_ORACLE_SCRIPT procedure provides a supported and effective way to execute restricted DDL statements, allowing invalid objects—such as PUBLIC SYNONYMS—to be recreated and validated successfully. Once the affected objects are corrected, recompilation completes successfully, datapatch can finish without errors, and both the PDB and CDB return to a healthy, fully valid state.