1. 创建未决区
DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA;
2.创建资源消费组
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(CONSUMER_GROUP => 'rudy01_consumer_group',
COMMENT => 'this is rudy test consumer group');
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(CONSUMER_GROUP => 'rudy02_consumer_group',
COMMENT => 'this is rudy test consumer group');
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(CONSUMER_GROUP => 'rudy03_consumer_group',
COMMENT => 'this is rudy test consumer group');
3.创建资源计划
DBMS_RESOURCE_MANAGER.CREATE_PLAN(PLAN => 'rudy_membership_plan',
CPU_MTH => 'RATIO',
COMMENT => 'this is a plan');
4.创建计划指示
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(PLAN => 'rudy_membership_plan',
GROUP_OR_SUBPLAN => 'rudy01_consumer_group',
COMMENT => 'this is a test plan directive',
CPU_P1 => 40);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(PLAN => 'rudy_membership_plan',
GROUP_OR_SUBPLAN => 'rudy02_consumer_group',
COMMENT => 'this is a test plan directive',
CPU_P1 => 30);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(PLAN => 'rudy_membership_plan',
GROUP_OR_SUBPLAN => 'rudy03_consumer_group',
COMMENT => 'this is a test plan directive',
CPU_P1 => 30);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(PLAN => 'rudy_membership_plan',
GROUP_OR_SUBPLAN => 'other_groups',
COMMENT => 'this is a test plan directive',
CPU_P1 => 0);
--注意如果你的电脑是单核cpu,就不要使用CPU_P2了,不然会报错
5.验证未决区
DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA;
6.提交未决区
DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA;
7.指派用户到消费组
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP(GRANTEE_NAME => 'scott',
CONSUMER_GROUP => 'rudy01_consumer_group',
GRANT_OPTION => TRUE);
DBMS_RESOURCE_MANAGER.SET_INITIAL_CONSUMER_GROUP(USER => 'scott',
CONSUMER_GROUP => 'rudy01_consumer_group');