可使用登陆触发器实现,但只对非 dba 用户帐户和通过 tcp/ip 协议登陆的客户端有效。create or replace trigger logon_limit_trg after logon on database declare cnt number(2); begin select count(1) into cnt from v$session where machine=sys_context('userenv','host') and port<>0; if cnt>10 then RAISE_APPLICATION_ERROR(-20001,'Beyond limit'); end if; end; /
-- Create profile
create profile limit
sessions_per_user 10
alter user uname profile limit;
alter profile default limit idle_time 30;或者可以设置每个session滞留时间,超过就自动kill掉了
sqlnet.ora文件,新增expire_time=x(单位是分钟)
after logon on database
declare
cnt number(2);
begin
select count(1) into cnt from v$session
where machine=sys_context('userenv','host') and port<>0;
if cnt>10 then
RAISE_APPLICATION_ERROR(-20001,'Beyond limit');
end if;
end;
/