( YT Video: https://youtu.be/onz8MM1H9DA )
To gather the Optimizer statistics for a table in a PDB, you need to login to the PDB and use the DBMS_STATS.GATHER_TABLE_STATS procedure.
You can either login directly to the PDB with the required privileges or login as prvilege user to the root container and then switch to the PDB.
Example:
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 23.26.0.0.0 - Production on Tue Nov 25 13:46:22 2025
Version 23.26.0.0.0
Copyright (c) 1982, 2025, Oracle. All rights reserved.
Connected to:
Oracle AI Database 26ai Free Release 23.26.0.0.0 - Develop, Learn, and Run for Free
Version 23.26.0.0.0
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container=FREEPDB1;
Session altered.
SQL>
SQL> begin
2 dbms_stats.gather_table_stats(
3 ownname => 'HR',
4 tabname => 'EMPLOYEES'
5 );
6 END;
7 /
PL/SQL procedure successfully completed.
SQL>
=======================================================================
** Email to info@shreyantech.com to get the Tip of the Day in your mailbox.
No comments:
Post a Comment