Profile实验
根据我们探讨的Profile功能,我们进行一个简单的小实验。
首先我们创建一个自定义Profile,要求应用该Profile的用户,一次只能有一个用户Session连入到数据库中。
-- Create profile
create profile ONESESSION limit
sessions_per_user 1;
创建一个Profile,在session_per_user中设置1,表示一次只允许一个用户形成会话。其余的参数选项均选择Default值。
将该Profile设置给scott用户。
-- Add users to profile
alter user scott profile ONESESSION;
下面,有一个比较重要的步骤。如果不设置上,就无法让我们的资源限制profile生效。
在Oracle中,有一个系统参数为resource_limit,默认值为false。表示不启用资源限制功能。应用资源Profile管理的时候,要将它修改为true。
//查看参数
SQL> show parameter resource_limit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
resource_limit boolean FALSE
//修改参数
SQL> alter system set resource_limit=true scope=memory;
System altered
//确定参数修改
SQL> show parameter resource_limit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
resource_limit boolean TRUE
以scott用户登录。
SQL> conn scott/tiger@wilson;
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as scott
当在另一个窗口,尝试登录的时候。
SQL> conn scott/tiger@wilson;
ERROR:
ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit
报错,说明资源限制的Profile已经应用上。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17203031/viewspace-683491/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/17203031/viewspace-683491/