2 Replies Latest reply on Apr 9, 2019 9:01 AM by Markus Flechtner

    ORA-01031: insufficient privileges when looping through all PDBs as SYSDBA

    TheLonelyDBA

      Hi,

       

      I have this short PLSQL code to loop through all PDBs:

       

      set serveroutput on

      declare

      cursor rec

      is

      select name, open_mode

              from v$pdbs

              where name not in ('PDB$SEED');

       

      begin

      for x in rec

      loop

      execute immediate 'alter session set container= "' || x.name || '"';

      DBMS_OUTPUT.put_line(x.name);

      end loop;

      end;

      /  2    3    4    5    6    7    8    9   10   11   12   13   14   15

      declare

      *

      ERROR at line 1:

      ORA-01031: insufficient privileges

      ORA-06512: at line 11

      ORA-06512: at line 11

       

      I run this as SYSDBA. After the script terminates I have changed PDB to the first one. Is there a way to loop through PDBs and do the same stuff in all of them?

       

      Regards

      TheLonelyDBA