<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="create-resource-group">
      </a>
      15.7.2.2 CREATE RESOURCE GROUP Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045172810080">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74831828"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> <em class="replaceable">group_name</em>
    <span class="token keyword">TYPE</span> <span class="token operator">=</span> {<span class="token keyword">SYSTEM</span><span class="token operator">|</span><span class="token keyword">USER</span>}
    <span class="token punctuation">[</span><span class="token keyword">VCPU</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <em class="replaceable">vcpu_spec</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">vcpu_spec</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">THREAD_PRIORITY</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <em class="replaceable">N</em><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">ENABLE</span><span class="token operator">|</span><span class="token keyword">DISABLE</span><span class="token punctuation">]</span>

<em class="replaceable">vcpu_spec</em>: {<em class="replaceable">N</em> <span class="token operator">|</span> <em class="replaceable">M</em> <span class="token operator">-</span> <em class="replaceable">N</em>}</code></pre>
  </div>
  <p>
   <a class="link" href="create-resource-group.html" title="15.7.2.2 CREATE RESOURCE GROUP Statement">
    <code class="literal">
     CREATE RESOURCE GROUP
    </code>
   </a>
   is used for
        resource group management (see
   <a class="xref" href="resource-groups.html" title="7.1.16 Resource Groups">
    Section 7.1.16, “Resource Groups”
   </a>
   ). This statement creates a new
        resource group and assigns its initial attribute values. It
        requires the
   <a class="link" href="privileges-provided.html#priv_resource-group-admin">
    <code class="literal">
     RESOURCE_GROUP_ADMIN
    </code>
   </a>
   privilege.
  </p>
  <p>
   <em class="replaceable">
    <code>
     group_name
    </code>
   </em>
   identifies which resource
        group to create. If the group already exists, an error occurs.
  </p>
  <p>
   The
   <code class="literal">
    TYPE
   </code>
   attribute is required. It should be
   <code class="literal">
    SYSTEM
   </code>
   for a system resource group,
   <code class="literal">
    USER
   </code>
   for a user resource group. The group
        type affects permitted
   <code class="literal">
    THREAD_PRIORITY
   </code>
   values, as described later.
  </p>
  <p>
   The
   <code class="literal">
    VCPU
   </code>
   attribute indicates the CPU
        affinity; that is, the set of virtual CPUs the group can use:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If
      <code class="literal">
       VCPU
      </code>
      is not given, the resource group
            has no CPU affinity and can use all available CPUs.
     </p>
    </li>
    <li class="listitem">
     <p>
      If
      <code class="literal">
       VCPU
      </code>
      is given, the attribute value is
            a list of comma-separated CPU numbers or ranges:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Each number must be an integer in the range from 0 to
                the number of CPUs − 1. For example, on a system
                with 64 CPUs, the number can range from 0 to 63.
        </p>
       </li>
       <li class="listitem">
        <p>
         A range is given in the form
         <em class="replaceable">
          <code>
           M
          </code>
         </em>
         −
         <em class="replaceable">
          <code>
           N
          </code>
         </em>
         , where
         <em class="replaceable">
          <code>
           M
          </code>
         </em>
         is less than or equal to
         <em class="replaceable">
          <code>
           N
          </code>
         </em>
         and both numbers are in the
                CPU range.
        </p>
       </li>
       <li class="listitem">
        <p>
         If a CPU number is an integer outside the permitted
                range or is not an integer, an error occurs.
        </p>
       </li>
      </ul>
     </div>
    </li>
   </ul>
  </div>
  <p>
   Example
   <code class="literal">
    VCPU
   </code>
   specifiers (these are all
        equivalent):
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81511145"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">,</span><span class="token number">10</span>
<span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token operator">-</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token operator">-</span><span class="token number">10</span>
<span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">9</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">3</span>
<span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">2</span></code></pre>
  </div>
  <p>
   The
   <code class="literal">
    THREAD_PRIORITY
   </code>
   attribute indicates the
        priority for threads assigned to the group:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If
      <code class="literal">
       THREAD_PRIORITY
      </code>
      is not given, the
            default priority is 0.
     </p>
    </li>
    <li class="listitem">
     <p>
      If
      <code class="literal">
       THREAD_PRIORITY
      </code>
      is given, the
            attribute value must be in the range from -20 (highest
            priority) to 19 (lowest priority). The priority for system
            resource groups must be in the range from -20 to 0. The
            priority for user resource groups must be in the range from
            0 to 19. Use of different ranges for system and user groups
            ensures that user threads never have a higher priority than
            system threads.
     </p>
    </li>
   </ul>
  </div>
  <p>
   <code class="literal">
    ENABLE
   </code>
   and
   <code class="literal">
    DISABLE
   </code>
   specify
        that the resource group is initially enabled or disabled. If
        neither is specified, the group is enabled by default. A
        disabled group cannot have threads assigned to it.
  </p>
  <p>
   Examples:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Create an enabled user group that has a single CPU and the
            lowest priority:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa83031556"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> rg1
  <span class="token keyword">TYPE</span> <span class="token operator">=</span> <span class="token keyword">USER</span>
  <span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">0</span>
  <span class="token keyword">THREAD_PRIORITY</span> <span class="token operator">=</span> <span class="token number">19</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Create a disabled system group that has no CPU affinity (can
            use all CPUs) and the highest priority:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60441907"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> rg2
  <span class="token keyword">TYPE</span> <span class="token operator">=</span> <span class="token keyword">SYSTEM</span>
  <span class="token keyword">THREAD_PRIORITY</span> <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">20</span>
  <span class="token keyword">DISABLE</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   Resource group management is local to the server on which it
        occurs.
   <a class="link" href="create-resource-group.html" title="15.7.2.2 CREATE RESOURCE GROUP Statement">
    <code class="literal">
     CREATE RESOURCE GROUP
    </code>
   </a>
   statements are not written to the binary log and are not
        replicated.
  </p>
 </div>
 <br/>
</div>
