1. 在sys模式下创建一个表,用于记录客户端登录数据库服务器的详细信息
create table logon_logs ( logon_time date, username varchar2(30), machine varchar2(64), ipadr varchar2(30), program varchar2(64), module varchar2(64), terminal varchar2(64) );
2.在sys模式下创建一个触发器:
create or replace trigger logusersconnects after logon on database begin insert into logon_logs values(sysdate, user,sys_context('USERENV','HOST'), sys_context('USERENV','IP_ADDRESS'), sys_context('USERENV','ACTION'), sys_context('USERENV','MODULE'), sys_context('USERENV','TERMINAL')); commit; end; /
3. 一些查看session数的实例(以sys用户登录)
--查看login_history表
select * from logon_logs;
--查看当前的所有session数
select count(*) from v$session;
--查看当前的客户端计算机名为RHEL的所有session数
select count(*) from v$session where machine = 'RHEL';
--查看当前的各个客户端计算机的连接数
select count(*) , machine from v$session group by machine;