
-- create application owner account
CREATE USER core IDENTIFIED BY "C0re....2021..."
DEFAULT TABLESPACE DATA
TEMPORARY TABLESPACE TEMP
QUOTA UNLIMITED ON DATA;
--
GRANT CONNECT                   TO core;
GRANT ALTER SESSION             TO core;
GRANT CREATE TABLE              TO core;
GRANT CREATE VIEW               TO core;
GRANT CREATE MATERIALIZED VIEW  TO core;
GRANT CREATE TRIGGER            TO core;
GRANT CREATE SEQUENCE           TO core;
GRANT CREATE PROCEDURE          TO core;
GRANT CREATE JOB                TO core;
--
--GRANT EXECUTE ON DBMS_EPG               TO core;
--GRANT EXECUTE ON DBMS_CRYPTO            TO core;
--GRANT EXECUTE ON DBMS_LOCK              TO core;
GRANT EXECUTE ON DBMS_UTILITY           TO core;
GRANT EXECUTE ON DBMS_APPLICATION_INFO  TO core;
GRANT EXECUTE ON DBMS_SESSION           TO core;  -- grant to user not role
GRANT EXECUTE ON DBMS_SCHEDULER         TO core;
GRANT EXECUTE ON DBMS_TRACE             TO core;
GRANT EXECUTE ON DBMS_PROFILER          TO core;
--GRANT EXECUTE ON DBMS_HPROF             TO core;
--
GRANT SELECT ON v_$sql              TO core;
GRANT SELECT ON v_$sql_cursor       TO core;
GRANT SELECT ON v_$session          TO core;
GRANT SELECT ON v_$session_longops  TO core;



ALTER SESSION SET CURRENT_SCHEMA = core;
--
CREATE OR REPLACE TRIGGER core.logon_init
AFTER LOGON ON SCHEMA
BEGIN
    DBMS_SESSION.SET_NLS('NLS_LANGUAGE',            '''ENGLISH''');
    DBMS_SESSION.SET_NLS('NLS_TERRITORY',           '''CZECH REPUBLIC''');
    DBMS_SESSION.SET_NLS('NLS_NUMERIC_CHARACTERS',  '''. ''');
    DBMS_SESSION.SET_NLS('NLS_DATE_FORMAT',         '''YYYY-MM-DD HH24:MI:SS''');
    DBMS_SESSION.SET_NLS('NLS_TIME_FORMAT',         '''HH24:MI:SSXFF''');
    DBMS_SESSION.SET_NLS('NLS_TIMESTAMP_FORMAT',    '''YYYY-MM-DD HH24:MI:SSXFF''');
    DBMS_SESSION.SET_NLS('NLS_TIME_TZ_FORMAT',      '''HH24:MI:SSXFF TZR''');
    DBMS_SESSION.SET_NLS('NLS_TIMESTAMP_TZ_FORMAT', '''YYYY-MM-DD HH24:MI:SSXFF TZR''');
    DBMS_SESSION.SET_NLS('NLS_SORT',                '''BINARY_AI''');
    DBMS_SESSION.SET_NLS('NLS_COMP',                '''LINGUISTIC''');
    --
    
    --ALTER SESSION SET TIME_ZONE = '+02:00';

END;
/



BEGIN
    APEX_INSTANCE_ADMIN.SET_PARAMETER (
        p_parameter => 'CLONE_SESSION_ENABLED',
        p_value     => 'Y'
    );
    COMMIT;
END;
/

