Occasionally, we meet customers with thousands of schemas, a challenge that can seem overwhelming to add schematrandata, for example. However, by utilizing the right script, you can effortlessly generate your obey file and execute it in the AdminClient, transforming complexity into clarity.

DEFINE ggadmin_user = 'OGGADMIN'
SPOOL </path>/schematrandata_commands.obey

SET SERVEROUTPUT ON SIZE UNLIMITED
SET FEEDBACK OFF
SET TRIMSPOOL ON

BEGIN
  FOR r IN (
    SELECT username 
    FROM dba_users 
    WHERE 
      account_status = 'OPEN' 
      AND oracle_maintained = 'N'
      AND default_tablespace NOT IN ('SYSTEM','SYSAUX')
      AND username NOT IN ('&ggadmin_user','PDBADMIN')
  ) 
  LOOP
    BEGIN
      DBMS_OUTPUT.PUT_LINE('ADD SCHEMATRANDATA ' || r.username || ' ALLCOLS');
      --DBMS_OUTPUT.PUT_LINE('-- DELETE SCHEMATRANDATA ' || r.username);
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('-- Failed for ' || r.username || ': ' || SQLERRM);
    END;
  END LOOP;
END;
/

SPOOL OFF

Bonus:

If you have 1000s of tables in your extract parameter file, e.g., TABLE ALIMA.TABLE1; you can use the command below to generate your Mappings for your replicat file:

cut -f 1 -d ","  $1  | awk -F . '{print "MAP ALIMA."$NF", TARGET ALIMA."$NF";"}'

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.