A proxy user allows one database user to act on behalf of another. This functionality is particularly useful for managing access in a secure and controlled way. Somtimes improving administration and user management efficiency.
A proxy user is a user account that can connect and work on behalf of another user without needing their password. This delegation allows for access control while still enabling multiple users or applications to interact with a single database account.
CREATE USER schema_user1 IDENTIFIED BY password1;
CREATE USER schema_user2 IDENTIFIED BY password2;
GRANT CONNECT, RESOURCE TO schema_user1;
GRANT CONNECT, RESOURCE TO schema_user2;
CREATE USER proxy_user IDENTIFIED BY proxy_password;
GRANT CONNECT TO proxy_user;
ALTER USER schema_user1 GRANT CONNECT THROUGH proxy_user;
ALTER USER schema_user2 GRANT CONNECT THROUGH proxy_user;
You can connect as the proxy user to act as schema_user1 or schema_user2:
CONNECT proxy_user[schema_user1]/proxy_password@db;
In this setup, the proxy_user can now connect and work on behalf of schema_user1 and schema_user2 without needing their passwords, providing controlled access.
In addition to managing proxy users, Oracle provides profiles to control session behavior and resource usage. See my post about users and profiles. Here we define limits for idle time as an example using profiles. Idle time determines how long a session can remain inactive before being disconnected.
Let’s create three profiles, each with a different idle time, and see how they affect session behavior.
Create profiles with different idle times:
CREATE PROFILE profile_1 LIMIT IDLE_TIME 1; -- 1 minute idle time
CREATE PROFILE profile_2 LIMIT IDLE_TIME 20; -- 2 minutes idle time
CREATE PROFILE profile_proxy LIMIT IDLE_TIME 5; -- 3 minutes idle time
ALTER USER schema_user1 PROFILE profile_1;
ALTER USER schema_user2 PROFILE profile_2;
ALTER USER proxy_user PROFILE profile_proxy;
By controlling idle time via profiles, you can fine-tune resource usage and session management in your Oracle database.
BTWת If no profile is assigned to the proxy_user, Oracle will apply the default profile
.
The default profile
usually has no strict resource limits unless explicitly modified by the DBA.
This means:
By not defining a profile, you’re leaving session behavior and resource usage less controlled, which might affect performance or security in certain cases.
SELECT PROXY, CLIENT FROM DBA_PROXIES;