DROP USER CT_MRDS CASCADE;


CREATE USER CT_MRDS IDENTIFIED BY Start_1234567890
   DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;
ALTER USER CT_MRDS QUOTA UNLIMITED ON DATA;


EXEC DBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL(username => 'CT_MRDS');

-- Cloud and database privileges (MARS-770)
GRANT EXECUTE ON DBMS_CLOUD TO CT_MRDS; 
GRANT INHERIT PRIVILEGES ON USER ADMIN TO CT_MRDS;
GRANT INHERIT PRIVILEGES ON USER PDBADMIN TO CT_MRDS;
GRANT INHERIT PRIVILEGES ON USER PDBSOFA TO CT_MRDS;
GRANT INHERIT PRIVILEGES ON USER MRDS_LOADER TO CT_MRDS;

-- Grant DBMS_CRYPTO for package hash calculation (SHA256)
GRANT EXECUTE ON DBMS_CRYPTO TO CT_MRDS;

-- Grant SELECT ANY DICTIONARY for cross-schema package hash tracking (MARS-1049)
-- Allows ENV_MANAGER to read ALL_SOURCE for packages in ODS and other schemas
-- Required for CALCULATE_PACKAGE_HASH to work across schemas
GRANT SELECT ANY DICTIONARY TO CT_MRDS; 
