둥둥둥
07/01/2026, 7:53 AMRocky
07/01/2026, 7:54 AMALTER RESOURCE GROUP statement.
Syntax
sql
ALTER RESOURCE GROUP <group_name> ADD (user='<user_name>');
Examples
* Assign a single user:
sql
ALTER RESOURCE GROUP my_group ADD (user='alice');
* Assign a user with specific conditions (e.g., only for SELECT queries):
sql
ALTER RESOURCE GROUP my_group ADD (user='bob', query_type in ('select'));
Important Notes
1. Multiple Classifiers: A resource group can have multiple classifiers. When a user runs a query, StarRocks matches the query to the best-fitting classifier to determine which resource group to use.
2. Verification: You can check the current classifiers and their IDs for a resource group by running:
sql
SHOW RESOURCE GROUP <group_name>;
3. Roles: You can also assign entire roles to a resource group instead of individual users:
sql
ALTER RESOURCE GROUP my_group ADD (role='analyst_role');
References
• administration/management/resource_management/resource_group.md
• sql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.mdRocky
07/01/2026, 7:54 AMALTER RESOURCE GROUP statement to add a new classifier.
Syntax
sql
ALTER RESOURCE GROUP <group_name> ADD (user='<user_name>');
Examples
* Add a specific user:
sql
ALTER RESOURCE GROUP my_group ADD (user='alice');
* Add a user with additional conditions (e.g., only for SELECT queries):
sql
ALTER RESOURCE GROUP my_group ADD (user='bob', query_type in ('select'));
* Add a role instead of a user:
sql
ALTER RESOURCE GROUP my_group ADD (role='analyst');
Key Details
• Classifiers: A resource group can have multiple classifiers. When a user runs a query, StarRocks matches the query against these classifiers to determine which resource group to use.
• Viewing Current Users: To see which users/classifiers are already assigned to a group, run:
sql
SHOW RESOURCE GROUP <group_name>;
• Privileges: This operation requires the ALTER privilege on the target resource group.
References
• sql-reference/sql-statements/cluster-management/resource_group/ALTER_RESOURCE_GROUP.md
• administration/management/resource_management/resource_group.md
• sql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.mdRocky
07/01/2026, 7:54 AMsql
ALTER RESOURCE GROUP <group_name> ADD (user='<user_name>');
Example:
sql
-- Adds user 'jack' to the resource group 'production_rg'
ALTER RESOURCE GROUP production_rg ADD (user='jack');
2. Manual Session Assignment
If you want a user to manually switch to a specific resource group for their current session, they can use a session variable. This overrides the automatic classifier matching.
Syntax:
sql
SET resource_group = '<group_name>';
Example:
sql
-- The current user switches to 'analytics_rg' for this session
SET resource_group = 'analytics_rg';
3. Verify the Assignment
To see which users or classifiers are currently assigned to a resource group, use:
sql
SHOW RESOURCE GROUP <group_name>;
Note on Pre-requisites
* Privileges: You must have the ALTER privilege on the resource group to add a user via a classifier.
* Pipeline Engine: Resource groups require the Pipeline Engine to be enabled (it is enabled by default in v3.1.0+).
References
• administration/management/resource_management/resource_group.md
• sql-reference/sql-statements/cluster-management/resource_group/ALTER_RESOURCE_GROUP.md
• sql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.md
References
• administration/management/resource_management/resource_group.md
• sql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.md
• sql-reference/sql-statements/cluster-management/resource_group/ALTER_RESOURCE_GROUP.md
• sql-reference/sql-statements/account-management/ALTER_USER.mdRocky
07/01/2026, 7:55 AMRESOURCE GROUP = '...' directly inside the basic CREATE USER command for versions earlier than v3.3.3. However, depending on your version, you can achieve this in one or two steps.
Method 1: Using User Properties (StarRocks v3.3.3 and later)
From version 3.3.3 onwards, StarRocks allows you to set session variables as user properties during the CREATE USER process. Since resource_group is a session variable, you can assign it directly.
Syntax:
sql
CREATE USER 'jack'@'%'
IDENTIFIED BY 'your_password'
PROPERTIES ("session.resource_group" = "your_rg_name");
Method 2: The Two-Step Approach (Recommended for All Versions)
This is the standard administrative workflow. You first create the user, then associate that user with a resource group by adding a classifier.
1. Create the user:
sql
CREATE USER 'jack'@'%' IDENTIFIED BY 'your_password';
2. Assign to the resource group:
sql
ALTER RESOURCE GROUP your_rg_name ADD (user='jack');
Why Method 2 is often better:
* Decoupling: Resource management is handled by the resource group, not the user object.
* Granularity: Using ALTER RESOURCE GROUP allows you to add more specific conditions (e.g., "only assign jack to this group when he is running SELECT queries").
* Visibility: Running SHOW RESOURCE GROUPS ALL; clearly shows which users are mapped to which groups via their classifiers.
Summary of Differences
Feature | CREATE USER ... PROPERTIES | ALTER RESOURCE GROUP ... ADD
StarRocks Version | v3.3.3+ | All versions
Mechanism | Session Variable | Classifier Matching
Flexibility | Static (one group per user) | High (can vary by IP, query type, etc.)
References
• sql-reference/sql-statements/account-management/CREATE_USER.md
• administration/management/resource_management/resource_group.md
• sql-reference/System_variable.md
References
• sql-reference/System_variable.md
• faq/resource_isolation_faq.md
• administration/management/resource_management/resource_group.md둥둥둥
07/01/2026, 7:56 AMRocky
07/01/2026, 7:56 AMPROPERTIES clause in the CREATE USER statement to set the resource_group session variable directly for that user.
Syntax:
sql
CREATE USER 'username'@'%'
IDENTIFIED BY 'password'
PROPERTIES ("session.resource_group" = "your_rg_name");
* How it works: This sets a user-level property. Every time this user logs in, StarRocks automatically sets their session variable resource_group to the specified value.
For Versions earlier than v3.3.3
There is no single command to do both. You must follow a two-step process:
1. Create the user:
sql
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
2. Assign the user to the group via a classifier:
sql
ALTER RESOURCE GROUP your_rg_name ADD (user='username');
Which method should you use?
* Use PROPERTIES (v3.3.3+): If you want a hard-coded default group for a specific user regardless of where they connect from or what they are doing.
* Use ALTER RESOURCE GROUP (Classifiers): If you want more flexibility. Classifiers allow you to assign a user to different groups based on conditions like their source IP, the database they are accessing, or the type of query (e.g., SELECT vs INSERT).
To verify the assignment:
sql
-- To see user-level properties:
SHOW PROPERTY FOR 'username';
-- To see resource group mappings:
SHOW RESOURCE GROUPS ALL;
References
• sql-reference/sql-statements/account-management/CREATE_USER.md
• administration/management/resource_management/resource_group.md
• sql-reference/System_variable.md
References
• sql-reference/sql-statements/account-management/CREATE_USER.md
• sql-reference/System_variable.md
• sql-reference/sql-statements/account-management/ALTER_USER.md둥둥둥
07/01/2026, 8:14 AM둥둥둥
07/01/2026, 8:16 AMRocky
07/01/2026, 8:16 AMCREATE RESOURCE GROUP syntax typically requires at least one classifier to be defined during the initial creation.
Here is the breakdown of how to handle this:
1. Creation Syntax Requirement
According to the official StarRocks syntax, the TO clause (which defines classifiers) is a standard part of the command. If you try to omit it entirely, the SQL parser may return a syntax error.
sql
-- Standard syntax
CREATE RESOURCE GROUP <name>
TO (user='dummy_user') -- Usually requires at least one classifier
WITH ('cpu_weight' = '10', 'mem_limit' = '20%');
2. How to "Empty" a Resource Group
If you want a resource group to have no classifiers (for example, if you only plan to assign queries to it manually via session variables), you can follow these steps:
1. Create it with any classifier (e.g., a dummy user or your own account).
2. Drop all classifiers using the ALTER command:
sql
ALTER RESOURCE GROUP <group_name> DROP ALL;
Once all classifiers are dropped, no queries will be automatically routed to this group based on user, role, or IP.
3. Using a Group Without Classifiers
A resource group without classifiers is still functional. You can use it by manually assigning it at the session or user level:
* Manual session assignment:
sql
SET resource_group = 'your_group_name';
* User-level property (v3.3.3+):
sql
ALTER USER 'username' SET PROPERTIES ("session.resource_group" = "your_group_name");
Summary
* Is it mandatory at creation? Technically yes, the TO clause is part of the CREATE statement grammar.
* Can a group exist without one? Yes, by using ALTER ... DROP ALL.
* Why do this? You might want a "quarantine" group or a special group that users must explicitly opt-into for specific heavy workloads, preventing any accidental automatic matching.
References
• sql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.md
• sql-reference/sql-statements/cluster-management/resource_group/ALTER_RESOURCE_GROUP.md
• administration/management/resource_management/resource_group.md
References
• sql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.md
• administration/management/resource_management/resource_group.md
• sql-reference/sql-statements/Resource/CREATE_RESOURCE.md둥둥둥
07/01/2026, 8:23 AMRocky
07/01/2026, 8:23 AMSELECT, INSERT, or CREATE TABLE) so they can be assigned to multiple users at once. This includes built-in roles like db_admin and cluster_admin.
2. Resource Group Assignment (Classifiers)
This is the most common use of Roles outside of security. You can use a Role as a Classifier for a Resource Group. This allows you to automatically control the hardware resources (CPU, Memory, IO) for anyone holding that role.
Example:
If you have a role called data_analyst, you can create a resource group that automatically limits or prioritizes their queries:
sql
-- Create a resource group specifically for analysts
CREATE RESOURCE GROUP analyst_group
TO (role='data_analyst') -- Use the role as a classifier
WITH (
"cpu_weight" = "10",
"mem_limit" = "30%"
);
Why this is useful:
* Automatic Routing: Instead of manually assigning every new analyst to a resource group, simply granting them the data_analyst role will automatically subject their queries to that group's resource limits.
* Dynamic Scaling: If you change a user's role, their resource priority changes immediately without needing to run ALTER RESOURCE GROUP commands.
Summary
* Privileges: Controls what a user can do (Security).
* Resource Groups: Controls how much resource a user can consume (Performance/Isolation). Roles serve as the bridge between these two systems.
References
• administration/management/resource_management/resource_group.md
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
References
• administration/management/resource_management/resource_group.md
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md둥둥둥
07/01/2026, 8:24 AMRocky
07/01/2026, 8:24 AMGRANT command.
Standard Syntax
sql
GRANT <role_name> TO USER <user_identity>;
Example
If you want to grant the role data_analyst to the user jack connecting from any host ('%'):
sql
GRANT data_analyst TO USER 'jack'@'%';
──────────
Important Considerations
1. Activating the Role
By default, granting a role does not necessarily mean it is active the moment the user logs in. You have two ways to handle this:
* Set as Default Role: This makes the role active automatically upon login.
sql
ALTER USER 'jack'@'%' DEFAULT ROLE 'data_analyst';
* Enable All Roles on Login (Recommended): You can configure StarRocks to automatically activate every role a user has been granted whenever they log in.
sql
SET GLOBAL activate_all_roles_on_login = TRUE;
2. Verification
To check which roles have been granted to a specific user:
sql
SHOW GRANTS FOR 'jack'@'%';
3. Required Privileges
To execute these commands, you typically need to be logged in as a user with the user_admin or root role.
References
• administration/user_privs/authorization/User_privilege.md
• sql-reference/sql-statements/account-management/GRANT.md
• sql-reference/sql-statements/account-management/ALTER_USER.md
References
• administration/user_privs/authorization/User_privilege.md
• sql-reference/sql-statements/account-management/GRANT.md
• sql-reference/sql-statements/account-management/ALTER_USER.md
• administration/user_privs/authorization/user_privs.md
References
• administration/user_privs/authorization/User_privilege.md
• administration/user_privs/authorization/user_privs.md둥둥둥
07/01/2026, 8:33 AMRocky
07/01/2026, 8:33 AMrole_a and role_b active, and both roles are tied to different resource groups, StarRocks uses a "Degree of Matching" (priority system) to decide which one to use.
How StarRocks Decides (The Priority Rules)
When multiple classifiers match a user's session, StarRocks calculates a score for each:
1. Number of Conditions: A classifier with more specific conditions wins.
_ _Example:* A classifier for (role='role_a', db='sales') will beat a classifier that only says (role='role_a').
2. Tie-Breaking (Accuracy): If they have the same number of conditions, the more "accurate" or restrictive one wins (e.g., a specific IP range beats a broader one).
3. Random Selection: If both classifiers are equally specific (e.g., both just specify a single role), StarRocks will randomly select one of the two resource groups.
Example Scenario
* User A has both role_a and role_b active.
* Resource Group X has a classifier: (role='role_a').
* Resource Group Y has a classifier: (role='role_b').
Because both classifiers have exactly one condition and the same weight (1.0), StarRocks will pick either Group X or Group Y randomly for the query.
Best Practices for Multiple Roles
To avoid random selection and ensure a specific role takes precedence, you can make one classifier more specific:
* Option A (More conditions): Add a database or query type to the preferred role's classifier.
* Option B (Manual override): The user can manually force a specific group for their current session:
sql
SET resource_group = 'group_x';
How to verify which group was used
You can check which resource group was actually selected for a query by looking at the ResourceGroup column in the FE audit log (fe.audit.log) or by running:
sql
EXPLAIN VERBOSE <your_query>;
References
• administration/management/resource_management/resource_group.md
• faq/resource_isolation_faq.md
• sql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.md
References
• faq/resource_isolation_faq.md
• administration/management/resource_management/resource_group.md둥둥둥
07/01/2026, 8:39 AMRocky
07/01/2026, 8:39 AManalyst_bob to have general access to a database via a role, but specific write access to one table granted only to him.
1. Create a Role for general privileges:
sql
CREATE ROLE general_access;
-- Grant basic USAGE/database-level access
GRANT USAGE ON DATABASE sales_db TO ROLE general_access;
-- Assign the role to the user
GRANT general_access TO USER 'analyst_bob'@'%';
2. Grant detailed privileges directly to the User:
sql
-- Grant specific table-level write access directly to the user identity
GRANT SELECT, INSERT, UPDATE ON TABLE sales_db.daily_report TO USER 'analyst_bob'@'%';
Result:
When analyst_bob logs in:
* He can see and enter the sales_db database (from the Role).
* He can perform SELECT, INSERT, and UPDATE on the daily_report table (from his direct User identity).
* He cannot perform those actions on other tables in that database unless the role or his identity specifically allows it.
Important Note on Activation
For the role-based privileges to work, the role must be active. You can ensure all granted roles are active by default for all users with this global setting:
sql
SET GLOBAL activate_all_roles_on_login = TRUE;
Why use this approach?
* Scalability: Use Roles for "Standard" access levels (e.g., "Developer", "Reader") that 90% of people use.
* Precision: Use direct User grants for "Exceptions" or highly sensitive tables that only one specific person should touch, without needing to create a brand new role for every single unique case.
References
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
• sql-reference/sql-statements/account-management/GRANT.md
References
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
• sql-reference/sql-statements/account-management/GRANT.md
References
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md둥둥둥
07/01/2026, 8:45 AMRocky
07/01/2026, 8:45 AMsql
CREATE RESOURCE_GROUP tenant_a_rg
CAPACITY (cpu_core_limit = 10, mem_limit = '20%')
INSERT CLASSIFIER (role = 'tenant_a_base_role');
_This ensures any user with the tenant_a_base_role active will automatically be governed by the tenant_a_rg resource limits._
2. Privilege Hierarchy (Roles + Direct Grants)
Since users within a tenant have different database privileges, use a tiered approach:
* Tier 1: The Tenant Admin Role
Create a "Manager" role for each tenant with WITH GRANT OPTION. This allows the tenant leader to manage their own users without needing a global cluster admin.
sql
GRANT ALL PRIVILEGES ON DATABASE tenant_a_db TO ROLE tenant_a_admin WITH GRANT OPTION;
GRANT USAGE ON CATALOG tenant_a_catalog TO ROLE tenant_a_admin WITH GRANT OPTION;
* Tier 2: Standard Tenant Roles
Create "template" roles for common patterns (e.g., tenant_a_read_only, tenant_a_developer).
sql
GRANT SELECT ON ALL TABLES IN DATABASE tenant_a_db TO ROLE tenant_a_read_only;
* Tier 3: Individual User Exceptions (Direct Grants)
For the users who need "different privileges" (e.g., one user needs access to a specific sensitive table that the standard role doesn't have), grant those directly to the User Identity.
sql
-- Grant general access via role
GRANT tenant_a_read_only TO USER 'bob'@'%';
-- Grant specific write access to one table only for Bob
GRANT INSERT, UPDATE ON TABLE tenant_a_db.specific_table TO USER 'bob'@'%';
3. Catalog Isolation
In a multi-tenant environment, metadata visibility is key.
* Visibility: Users can only see catalogs and databases they have USAGE or SELECT permissions for.
* Best Practice: Do not grant any privileges on the default_catalog or other tenants' catalogs to a tenant's roles. This keeps the environment clean; when a user runs SHOW CATALOGS, they only see what they own.
4. Automation & Maintenance
* Default Roles: To simplify the user experience, set the tenant's base role as the default for their users:
sql
ALTER USER 'bob'@'%' DEFAULT ROLE 'tenant_a_read_only';
* Automatic Activation: Enable global role activation so users don't have to run SET ROLE manually:
sql
SET GLOBAL activate_all_roles_on_login = TRUE;
Summary of the Best Practice Model
1. Resource Group: 1 per tenant (Classified by Role).
2. Database/Catalog: 1 or more per tenant.
3. Roles: Use for "Access Levels" (Admin, Dev, Read).
4. Direct Grants: Use for "Unique Exceptions" per user.
5. Delegation: Use WITH GRANT OPTION to let tenants self-manage.
References
• administration/user_privs/authorization/User_privilege.md
• administration/management/resource_management/resource_group.md
• sql-reference/sql-statements/account-management/GRANT.md
References
• administration/user_privs/authorization/User_privilege.mdRocky
07/01/2026, 8:45 AM둥둥둥
07/01/2026, 8:53 AM둥둥둥
07/01/2026, 8:53 AMRocky
07/01/2026, 8:53 AMsql
-- 1. Create the 'Base Role' for the tenant
CREATE ROLE tenant_a_base;
-- 2. Link the Resource Group to this specific role
CREATE RESOURCE_GROUP tenant_a_rg
CAPACITY (cpu_core_limit = 10)
INSERT CLASSIFIER (role = 'tenant_a_base');
2. The "Baseline" for Permissions
Instead of granting every user permission to see the tenant’s database one by one, you grant it to the Base Role. This ensures that anyone added to the tenant can at least "see" the environment.
* Example:
sql
-- Every user in Tenant A needs to see these to do anything
GRANT USAGE ON CATALOG tenant_a_catalog TO ROLE tenant_a_base;
GRANT USAGE ON DATABASE tenant_a_db TO ROLE tenant_a_base;
3. How it fits in a hierarchy
In a mature setup, the Tenant Base Role often sits at the bottom of a hierarchy. You might have several functional roles that all "inherit" the base role.
* Role Hierarchy Example:
* tenant_a_read_only (Inherits tenant_a_base)
* tenant_a_developer (Inherits tenant_a_base)
* tenant_a_admin (Inherits tenant_a_base)
Because all these roles inherit tenant_a_base, any user assigned any of these roles will automatically trigger the tenant_a_rg Resource Group because the base role is active in their session.
Summary: Why use one?
* Simplicity: You only need to maintain one Resource Group classifier per tenant.
* Security: It creates a "walled garden." If a user doesn't have the tenant_a_base role, they can't see the tenant's catalog or use their compute power.
* Cleanliness: When you run SHOW ROLES, it’s easy to see which roles belong to which customer (e.g., customer1_base, customer2_base).
References
• administration/user_privs/authorization/User_privilege.md
• administration/management/resource_management/resource_group.md
• administration/user_privs/authorization/user_privs.md
References
• administration/user_privs/authorization/User_privilege.md
• sql-reference/sql-statements/account-management/GRANT.md둥둥둥
07/01/2026, 9:00 AM둥둥둥
07/01/2026, 9:00 AMRocky
07/01/2026, 9:00 AMSELECT access to a new table.
* Without sharing roles: You would have to run 50 GRANT statements (one for each user). If that table is later deleted or restricted, you have to run 50 REVOKE statements.
* With a shared role: You grant the permission to the analyst role once. All 50 users immediately get access.
2. Standardizing "Job Functions"
A Role represents a job function, not a person. People join the company, change teams, or leave, but the "job function" of an "Accounting Auditor" or "Data Scientist" remains the same.
* When a new employee joins the "Marketing" team, you don't need to figure out which 20 tables they need. You simply give them the marketing_role, and they instantly have the exact same environment as their peers.
3. StarRocks Specific: Resource Isolation
In StarRocks, Resource Groups (which control CPU and Memory) are often tied to Roles via classifiers.
* If you have a "Tenant A" with 10 users, you want all 10 users to share the same 20% of cluster CPU.
* By putting all 10 users into a single tenant_a_base_role, StarRocks can easily identify them as one group and enforce that resource limit collectively.
4. Consistency and Compliance
Using shared roles prevents "permission creep." If every user has custom-granted permissions, it becomes nearly impossible for an auditor to verify that no one has accidental access to sensitive data. With roles, you only have to audit the role's permissions to know what every member can do.
When should a user have a unique grant?
You should use Direct User Grants (Identity-Based) only for exceptions:
* A temporary project where one specific person needs access to a table for 24 hours.
* A "Manager" who needs everything their team has (via the role) plus one highly sensitive HR table (via a direct grant).
Summary: You put multiple users in one role so that you can manage groups of people as a single entity, ensuring they have consistent permissions and share the same resource limits.
References
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
• administration/management/resource_management/resource_group.md
References
• administration/user_privs/authorization/User_privilege.md
• administration/user_privs/authorization/user_privs.md둥둥둥
07/02/2026, 12:41 AM