USERS


     -- Run this in your dev environment

     CREATE USER test1 IDENTIFIED BY new_password

     DEFAULT TABLESPACE default_tablespace

     TEMPORARY TABLESPACE temp_tablespace

     QUOTA 100M ON users;


DECLARE

    v_user_count NUMBER;

BEGIN

    SELECT COUNT(*)

    INTO v_user_count

    FROM dba_users

    WHERE username = 'TEST1';  -- Change 'TEST1' to the name of the user you are checking/creating.


    IF v_user_count = 0 THEN

        EXECUTE IMMEDIATE 'CREATE USER test1 IDENTIFIED BY user_password

                           DEFAULT TABLESPACE default_tablespace

                           TEMPORARY TABLESPACE temp_tablespace';

        DBMS_OUTPUT.PUT_LINE('User test1 created.');

    ELSE

        DBMS_OUTPUT.PUT_LINE('User test1 already exists.');

    END IF;

END;

/


     -- Run this in your dev environment to get the roles

     SELECT 'GRANT ' || granted_role || ' TO test1;' FROM dba_role_privs WHERE grantee = 'TEST1';


     -- Run this in your dev environment to get the object privileges

     SELECT 'GRANT ' || privilege || ' ON ' || owner || '.' || table_name || ' TO test1;' 

     FROM dba_tab_privs WHERE grantee = 'TEST1';


     -- Run this in your dev environment to get the system privileges

     SELECT 'GRANT ' || privilege || ' TO test1;' 

     FROM dba_sys_privs WHERE grantee = 'TEST1';


     ```bash

     sqlplus username/password@UAT @script.sql