用户到底属于哪个组------关于other_groups用户组

1.我理解other_groups用户组是这样的用户组:

一个oracle用户成为other_groups的条件有两个:
1)其已经连接上数据库,即有活动会话(呵呵,有点废话,不连数据库爱归哪组就归哪组,不会对数据库有影响)
2)其所在的初始组(initial consumer group,可以在dba_users中查看)在当前资源计划中没有涉及到
2.先介绍default_consumer_group:
一个用户被创建即被指派给此用户,即如果用户没有指派到任何用户组即被默认指派给该组


3.下面以用户MGR为例,先通过以下两个sql来查看MGR的初始用户组和其隶属的用户组
SQL> select username, initial_rsrc_consumer_group from dba_users where username='MGR';

USERNAME        INITIAL_RSRC_CONSUMER_GROUP
--------------- ------------------------------
MGR             DEFAULT_CONSUMER_GROUP

SQL> select grantee, granted_group from dba_rsrc_consumer_group_privs where grantee='MGR';

GRANTEE                        GRANTED_GROUP
------------------------------ --------------------
MGR                            OLTP
MGR                            DSS
MGR                            BATCH
可以看到MGR的初始组为DEFAULT_CONSUMER_GROUP,另外其还分别隶属于OLTP,DSS,BATCH用户组
4.创建如下计划
begin
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.create_plan(plan=>'daytime', comment=>'plan for normal working hours');
dbms_resource_manager.create_plan_directive(plan=>'daytime',group_or_subplan=>'sys_group', cpu_p1=>100,comment=>'11');
dbms_resource_manager.create_plan_directive(plan=>'daytime', group_or_subplan=>'oltp',cpu_p2=>100,comment=>'11');
dbms_resource_manager.create_plan_directive(plan=>'daytime', group_or_subplan=>'dss',cpu_p3=>50,comment=>'11');
dbms_resource_manager.create_plan_directive(plan=>'daytime',group_or_subplan=>'batch',cpu_p3=>50,comment=>'11');
dbms_resource_manager.create_plan_directive(plan=>'daytime',group_or_subplan=>'other_groups',cpu_p4=>100,comment=>'11');
dbms_resource_manager.validate_pending_area();
dbms_resource_manager.submit_pending_area();
end;

执行以下命令以使当前资源计划为daytime
SQL> alter system set resource_manager_plan='daytime';

System altered.

其中mgr的初始用户组(default_consumer_group)并没有在当前计划(daytime)中出现
SQL>  select username, resource_consumer_group from v$session where username is not null;

USERNAME        RESOURCE_CONSUMER_GROUP
--------------- --------------------------------
SYS             SYS_GROUP
MGR             OTHER_GROUPS
BATCH           BATCH
        .
        .
        .

我们会发现mgr在OTHER_GROUPS用户组;
由此可见,虽然mgr隶属于很多组如batch,dss,oltp,但其初始组默认是DEFAULT_CONSUMER_GROUP,而DEFAULT_CONSUMER_GROUP在daytime计划中并没有涉及,因此mgr在v$session中只能是other_groups

 

请使用浏览器的分享功能分享到微信等