In SQLDeveloper, I wanted to set dbms_application_info.set_module
every time I load up a connection. This way, my queries will be delineated as belonging to me in v$active_session_history and other views.
Create a file and name in connection_startup_script.sql
with whatever code you want to execute, such as:
BEGIN
DBMS_APPLICATION_INFO.SET_MODULE(
module_name => 'SQL Developer',
action_name => 'MMOISEN'
);
END;
/
In SQLDeveloper, navigate to Tools>Preferences>Database, and under Filename for connection startup script
click Browse and select your file.
Alternatively, under the search bar type in "startup" and then click database:
To verify it is working, open up a new connection, and run the following:
SELECT username, osuser, module, action
FROM v$session
WHERE 1=1
AND sid = SYS_CONTEXT('USERENV', 'SID')
;
And you should see the following output: