Lý Thành
08/26/2026, 8:57 AMRocky
08/26/2026, 8:57 AMLý Thành
08/26/2026, 8:57 AMRocky
08/26/2026, 8:57 AMWITH GRANT OPTION for roles: In StarRocks, the WITH GRANT OPTION clause is used when granting privileges (like SELECT, INSERT, etc.) on specific objects (like tables or databases) to allow the recipient to grant those same privileges to others. It is not supported for role assignments (granting one role to another user or role).
2. Syntax for granting roles: To grant a role to a user, the standard syntax is:
GRANT <role_name> TO USER <user_identity>;
Corrected Syntax
If you want to grant the role ops_admin to the user yendth, you should use:
sql
GRANT ops_admin TO USER 'yendth'@'%';
Managing Granting Rights
* For Roles: Managing roles (creating, dropping, and granting them to others) is restricted to users with the system-defined user_admin role. There is no "admin option" to allow a user to grant a specific role to others without having broader user management privileges.
* For Privileges: If you were granting a privilege (e.g., SELECT) and wanted the user to be able to pass it on, you would use:
sql
GRANT SELECT ON TABLE my_table TO USER 'yendth'@'%' WITH GRANT OPTION;
Note: After granting a role, the user may need to activate it using SET ROLE ops_admin; or SET ROLE ALL; during their session, unless it is set as their default role via ALTER USER 'yendth'@'%' DEFAULT ROLE ops_admin;.
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
• administration/management/FE_configuration.md
• administration/user_privs/authorization/privilege_item.md
• administration/user_privs/authorization/User_privilege.mdLý Thành
08/27/2026, 3:14 AMRocky
08/27/2026, 3:14 AMINSERT into Iceberg or Hive tables with a static partition clause and a target column list, StarRocks now validates that the named partition column actually exists. Previously, invalid partition columns might have been silently ignored; they now return a clear error.
* Array/Map Capacity Limits: To prevent data corruption, ARRAY and MAP constructors will now throw a CapacityLimitExceed error if the flattened result of a single chunk exceeds the addressable byte limit.
* Division & Zone Map Pruning: Division expressions with a non-constant divisor (e.g., 10 DIV column) are no longer treated as monotonic. This prevents "unsafe Zone Map pruning" that previously caused some queries to incorrectly skip rows.
* GIN Index & NULLs: The NOT MATCH predicate on columns with a GIN inverted index no longer returns rows where the value is NULL. This change aligns the behavior with standard SQL three-valued logic.
Critical Upgrade/Downgrade Note
If you are managing an upgrade to the 4.0 series:
* Do not downgrade from v4.0 directly to v3.5.0 or v3.5.1. This will cause metadata incompatibility and FE crashes. You must downgrade to v3.5.2 or later.
* Before downgrading from v4.0.2+ to older versions (v4.0.0/v4.0.1 or v3.5.2–v3.5.10), you must run:
SET GLOBAL enable_rewrite_simple_agg_to_meta_scan=false;
For the full list of bug fixes and improvements, you can refer to the official StarRocks v4.0 Release Notes.
References
• release_notes/release-3.3.md
• release_notes/release-2.3.md
• release_notes/release-2.5.md
• release_notes/release-4.0.mdLý Thành
08/27/2026, 3:14 AMRocky
08/27/2026, 3:14 AMALTER privilege on a table in StarRocks, the correct syntax is:
sql
GRANT ALTER ON TABLE dmapp TO USER 'hoangqv'@'%';
Key Corrections:
1. Privilege Name: Use ALTER instead of ALTER TABLE.
2. Object Specification: You must specify the object type. If dmapp is a table, use ON TABLE dmapp. If dmapp is a database and you want to grant the right to alter all tables within it, use ON ALL TABLES IN DATABASE dmapp.
3. User Identity: StarRocks identifies users in the format 'username'@'host'. If you haven't specified a host, 'hoangqv'@'%' is the standard way to refer to the user connecting from any host.
Related Examples:
* Grant Alter on a specific database:
GRANT ALTER ON DATABASE dmapp TO USER 'hoangqv'@'%';
* Grant Alter on all tables in a database:
GRANT ALTER ON ALL TABLES IN DATABASE dmapp TO USER 'hoangqv'@'%';
Note: Ensure you have the user_admin role or the GRANT privilege on the target object to execute this command.
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
• administration/user_privs/authorization/privilege_item.md
References
• sql-reference/sql-statements/account-management/GRANT.mdLý Thành
08/27/2026, 4:36 AMTIME_PROCESSING_DEFAULT decimal(20, 0) NULL COMMENT "",
LAST_SYN_DATE datetime NULL COMMENT "",
TIME_TAT_1 decimal(20, 0) NULL COMMENT "",
TIME_TAT_DEFAULT decimal(20, 0) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(SYS_RUN_DATE, ID)
DISTRIBUTED BY RANDOM
PARTITION BY trunct('date', SYS_RUN_DATE
chỗ này đúng chưa: PARTITION BY trunct('date', SYS_RUN_DATERocky
08/27/2026, 4:36 AMtrunct. Bạn cần dùng hàm date_trunc.
2. Đóng ngoặc: Bạn đang thiếu dấu đóng ngoặc ) cho biểu thức partition.
Cú pháp đúng (dành cho v3.1 trở lên):
Nếu bạn muốn chia partition tự động theo ngày dựa trên cột SYS_RUN_DATE, cú pháp sẽ là:
sql
PARTITION BY date_trunc('day', SYS_RUN_DATE)
(Lưu ý: Bạn có thể thay 'day' bằng 'month' hoặc 'year' tùy theo nhu cầu chia dữ liệu của mình).
Một số lưu ý quan trọng:
* Kiểu dữ liệu: Cột SYS_RUN_DATE phải có kiểu dữ liệu là DATE hoặc DATETIME.
* Tính năng Automatic Partitioning: Đây là tính năng giúp StarRocks tự động tạo partition mới khi có dữ liệu đổ vào, bạn không cần phải định nghĩa từng phân vùng bằng tay như trước.
* Kiểm tra phiên bản: Tính năng PARTITION BY date_trunc yêu cầu StarRocks phiên bản 3.1 trở lên. Nếu bạn dùng bản cũ hơn, bạn sẽ phải dùng cú pháp PARTITION BY RANGE.
Ví dụ hoàn thiện:
sql
CREATE TABLE your_table_name (
`SYS_RUN_DATE` DATE NOT NULL,
`ID` BIGINT NOT NULL,
`TIME_PROCESSING_DEFAULT` decimal(20, 0) NULL,
`LAST_SYN_DATE` datetime NULL,
`TIME_TAT_1` decimal(20, 0) NULL,
`TIME_TAT_DEFAULT` decimal(20, 0) NULL
) ENGINE=OLAP
DUPLICATE KEY(`SYS_RUN_DATE`, `ID`)
PARTITION BY date_trunc('day', SYS_RUN_DATE) -- Chỗ này đã sửa
DISTRIBUTED BY RANDOM;
References
• sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md
• table_design/data_distribution/Automatic_partitioning.md
• table_design/data_distribution/expression_partitioning.mdLý Thành
08/27/2026, 4:40 AMRocky
08/27/2026, 4:41 AM/processes không phải là một đường dẫn chuẩn của lệnh SHOW PROC.
Nếu bạn muốn kiểm tra các tiến trình đang chạy hoặc thông tin về các node trong cụm, bạn nên sử dụng các lệnh sau tùy theo mục đích:
1. Xem danh sách các truy vấn đang thực thi (Query List)
Để xem các truy vấn đang chạy và tài nguyên chúng tiêu thụ, hãy sử dụng:
* SHOW PROC '/current_queries'; (Xem trên FE hiện tại)
* SHOW PROC '/global_current_queries'; (Xem trên toàn bộ cụm - từ bản v3.2+)
* Hoặc lệnh chuẩn MySQL: SHOW PROCESSLIST;
2. Xem trạng thái các node trong cụm
Nếu bạn muốn kiểm tra trạng thái của các thành phần hệ thống:
* SHOW PROC '/backends'; (Kiểm tra trạng thái các node BE)
* SHOW PROC '/frontends'; (Kiểm tra trạng thái các node FE)
* SHOW PROC '/compute_nodes'; (Nếu bạn dùng kiến trúc Cloud-native)
3. Kiểm tra thông tin hệ thống khác
Bạn có thể xem tất cả các đường dẫn khả dụng bằng cách chạy:
sql
SHOW PROC '/';
Kết quả sẽ liệt kê các thư mục như /dbs, /jobs, /statistic, /monitor, v.v. để bạn có thể truy vấn sâu hơn.
Lưu ý: Để chạy lệnh SHOW PROC, tài khoản của bạn cần có quyền OPERATE cấp hệ thống.
References
• sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_PROC.md
• sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_PROCESSLIST.md
References
• sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_PROC.mdLý Thành
08/27/2026, 4:43 AMRocky
08/27/2026, 4:43 AMdtm_los_app_processing_hist_new, bạn cần sử dụng từ khóa FROM thay vì OF và dùng số nhiều PARTITIONS.
Cú pháp đúng là:
sql
SHOW PARTITIONS FROM dtm_los_app_processing_hist_new;
Một số tùy chọn hữu ích khác:
* Xem các partition mới nhất: (Hữu ích khi bảng có quá nhiều partition)
sql
SHOW PARTITIONS FROM dtm_los_app_processing_hist_new
ORDER BY PartitionId DESC
LIMIT 10;
* Lọc partition theo tên:
sql
SHOW PARTITIONS FROM dtm_los_app_processing_hist_new
WHERE PartitionName = 'p20231001';
* Xem chi tiết theo hàng (dễ đọc hơn trong terminal):
sql
SHOW PARTITIONS FROM dtm_los_app_processing_hist_new\G
Kết quả trả về sẽ giúp bạn kiểm tra:
• `PartitionName`: Tên của partition.
• `Range`: Khoảng giá trị của partition (để xác nhận hàm date_trunc bạn vừa tạo có hoạt động đúng không).
• DataSize & `RowCount`: Dung lượng và số lượng dòng trong từng phân vùng.
References
• sql-reference/sql-statements/table_bucket_part_index/SHOW_PARTITIONS.md
References
• sql-reference/sql-statements/table_bucket_part_index/SHOW_PARTITIONS.md
• sql-reference/information_schema/partitions.mdLý Thành
08/27/2026, 8:08 AMRocky
08/27/2026, 8:08 AMuser_admin (Recommended)
The user_admin is the built-in system-defined role specifically designed for user and privilege management.
* Capabilities: It can create, alter, and drop users; create, grant, revoke, and drop roles.
* Privilege: It is granted the GRANT privilege at the SYSTEM level.
* Usage: This is the best practice role for a dedicated security or account administrator to prevent using the full-privilege root account for daily tasks.
2. root
The root role is the superuser role in StarRocks.
* Capabilities: It has all privileges in the system, including those of user_admin, db_admin, and cluster_admin.
* Usage: By default, the initial root user is assigned this role. It is used for initial cluster setup and emergency administrative tasks.
Summary of System-Defined Roles
Role | User Management | Role Management | Grant/Revoke
root | ✅ Yes | ✅ Yes | ✅ Yes
user_admin | ✅ Yes | ✅ Yes | ✅ Yes
db_admin | ❌ No | ❌ No | ❌ No
cluster_admin | ❌ No | ❌ No | ❌ No
How to assign this responsibility:
If you want to allow a specific user to manage others, you can grant them the user_admin role:
sql
GRANT user_admin TO USER 'security_officer'@'%';
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
References
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/User_privilege.mdLý Thành
08/27/2026, 8:53 AMGRANT SELECT ON DATABASE autocall TO USER hoangqv;Rocky
08/27/2026, 8:53 AMSELECT thường được gán cho Tất cả các bảng (ALL TABLES) trong một Database hoặc sử dụng cú pháp rút gọn.
Dưới đây là các cách viết đúng để gán quyền đọc cho user hoangqv trên database `autocall`:
Cách 1: Sử dụng cú pháp ALL TABLES (Khuyên dùng)
Đây là cách tường minh nhất trong StarRocks:
sql
GRANT SELECT ON ALL TABLES IN DATABASE autocall TO USER 'hoangqv'@'%';
Cách 2: Sử dụng cú pháp rút gọn (Kiểu MySQL)
sql
GRANT SELECT ON autocall.* TO USER 'hoangqv'@'%';
Một số lưu ý quan trọng:
1. User Identity: Bạn nên viết đầy đủ identity của user là 'hoangqv'@'%' (hoặc host cụ thể) thay vì chỉ hoangqv để tránh lỗi cú pháp tùy thuộc vào phiên bản.
2. Quyền bổ sung: Nếu bạn muốn user này có thể xem cả View hoặc Materialized View trong database đó, bạn cần gán thêm:
sql
GRANT SELECT ON ALL VIEWS IN DATABASE autocall TO USER 'hoangqv'@'%';
GRANT SELECT ON ALL MATERIALIZED VIEWS IN DATABASE autocall TO USER 'hoangqv'@'%';
3. Quyền USAGE trên Catalog: Đảm bảo user đã có quyền USAGE trên catalog chứa database đó (mặc định là default_catalog):
sql
GRANT USAGE ON CATALOG default_catalog TO USER 'hoangqv'@'%';
Tại sao câu lệnh gốc của bạn có thể lỗi?
Trong StarRocks, GRANT ... ON DATABASE autocall thường chỉ áp dụng cho các quyền quản lý cấp database như CREATE TABLE, DROP, hoặc ALTER. Quyền SELECT là quyền trên dữ liệu (bảng/view), nên cần chỉ định rõ ALL TABLES IN DATABASE.
References
• sql-reference/sql-statements/account-management/GRANT.md
References
• sql-reference/sql-statements/account-management/GRANT.md
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/User_privilege.md