Lý Thành
08/11/2026, 2:24 PMbi_top_24h_pct_tbl (
symbol *varchar*(20) NOT NULL COMMENT "Trading pair, e.g. BICOUSDT",
sys_run_date date NULL DEFAULT (*CURRENT_DATE*()) COMMENT "",
fetched_at datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT "Row ingestion time",
open_time datetime NULL COMMENT "Stats window open time",
close_time datetime NULL COMMENT "Stats window close time",
open_price *decimal*(24, 8) NULL COMMENT "",
high_price *decimal*(24, 8) NULL COMMENT "",
low_price *decimal*(24, 8) NULL COMMENT "",
last_price *decimal*(24, 8) NULL COMMENT "",
last_qty *decimal*(24, 8) NULL COMMENT "",
price_change *decimal*(24, 8) NULL COMMENT "",
price_change_percent *decimal*(10, 4) NULL COMMENT "",
weighted_avg_price *decimal*(24, 8) NULL COMMENT "",
volume *decimal*(30, 8) NULL COMMENT "Base asset volume",
quote_volume *decimal*(30, 8) NULL COMMENT "Quote asset volume",
count *bigint*(20) NULL COMMENT "Number of trades",
first_id *bigint*(20) NULL COMMENT "",
last_id *bigint*(20) NULL COMMENT ""
) ENGINE=OLAP
PRIMARY *KEY*(symbol, sys_run_date)
PARTITION BY date_trunc('day', sys_run_date)
DISTRIBUTED BY HASH(symbol) BUCKETS 1
PROPERTIES (
"compression" = "LZ4",
"fast_schema_evolution" = "true",
"partition_live_number" = "5",
"replicated_storage" = "true",
"replication_num" = "2"
);Rocky
08/11/2026, 2:25 PMDEFAULT (CURRENT_DATE()).
In StarRocks, while CURRENT_DATE() is a valid function for queries, it is not supported as an expression-based default value using the DEFAULT (<expr>) syntax. The supported way to set a "current date" or "current time" as a default value is to use the CURRENT_TIMESTAMP keyword.
Recommended Fixes
1. Fix the Default Value
Change DEFAULT (CURRENT_DATE()) to DEFAULT CURRENT_TIMESTAMP. StarRocks allows CURRENT_TIMESTAMP as a default for DATE columns; it will automatically truncate the time part and store only the date.
2. Primary Key Columns must be NOT NULL
In a StarRocks Primary Key table, all columns included in the PRIMARY KEY (in your case, symbol and sys_run_date) must be defined as NOT NULL. Your current DDL defines sys_run_date as NULL.
Corrected SQL Snippet:
sql
CREATE TABLE `bi_top_24h_pct_tbl` (
`symbol` varchar(20) NOT NULL COMMENT "Trading pair, e.g. BICOUSDT",
-- Changed DEFAULT and set to NOT NULL
`sys_run_date` date NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT "",
`fetched_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT "Row ingestion time",
...
) ENGINE=OLAP
PRIMARY KEY(`symbol`, `sys_run_date`)
PARTITION BY date_trunc('day', `sys_run_date`)
DISTRIBUTED BY HASH(`symbol`) BUCKETS 1
PROPERTIES (
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "2"
);
Key Considerations
* Version Requirement: Your use of PARTITION BY date_trunc(...) (Expression Partitioning) requires StarRocks v3.0 or later. If you are on an older version, you must use standard range partitioning.
* Primary Key Constraints: In Primary Key tables, the partition column must be part of the Primary Key. Since sys_run_date is in your PRIMARY KEY(...) list, your expression partitioning is valid for versions 3.0+.
* Default Values: Only specific functions like CURRENT_TIMESTAMP, uuid(), and uuid_numeric() are supported as functional defaults. Most other functions cannot be used in the DEFAULT clause.
References
• faq/Others.md
• sql-reference/sql-functions/date-time-functions/current_timestamp.md
• sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md
• administration/management/timezone.mdLý Thành
08/11/2026, 2:31 PMfetched_at)
DISTRIBUTED BY HASH(symbol) BUCKETS 1
PROPERTIES (
"compression" = "LZ4",
"fast_schema_evolution" = "true",
"partition_live_number" = "5",
"replicated_storage" = "true",
"replication_num" = "2"
);
how to add above code to a masterialized vierw below:
CREATE MATERIALIZED VIEW starrocks_audit_db__.bi_top_24h_pct
REFRESH ASYNC *START*('2026-08-01 080000') EVERY (interval 5 minute)
DISTRIBUTED BY HASH(symbol) BUCKETS 1
ASRocky
08/11/2026, 2:32 PMCREATE statement but before the AS clause.
Note that some properties from your table definition (like fast_schema_evolution and replicated_storage) are specific to OLAP Primary Key tables and do not apply to Materialized Views. For MVs, you should use partition_ttl_number to manage the number of active partitions.
Final Materialized View SQL
sql
CREATE MATERIALIZED VIEW starrocks_audit_db__.bi_top_24h_pct
-- 1. Partitioning (requires StarRocks 3.0+)
PARTITION BY date_trunc('day', `fetched_at`)
-- 2. Distribution
DISTRIBUTED BY HASH(`symbol`) BUCKETS 1
-- 3. Refresh Schedule
REFRESH ASYNC START('2026-08-01 08:00:00') EVERY (interval 5 minute)
-- 4. Properties (Note: partition_ttl_number is the MV equivalent of partition_live_number)
PROPERTIES (
"replication_num" = "2",
"partition_ttl_number" = "5",
"compression" = "LZ4"
)
AS
SELECT
symbol,
fetched_at,
-- Ensure you include all columns needed from the source table
open_time,
close_time,
last_price,
volume
FROM your_source_table;
Key Changes and Explanations:
* Placement: The PARTITION BY, DISTRIBUTED BY, REFRESH, and PROPERTIES clauses must all appear before the AS keyword.
* Partitioning: Using date_trunc('day', fetched_at) is supported in asynchronous MVs starting from StarRocks v3.0. Ensure fetched_at is included in your SELECT list.
* Property Mapping:
* partition_ttl_number: In Materialized Views, this property is used to limit the number of partitions kept (equivalent to partition_live_number in tables).
* Removed fast_schema_evolution: This is an optimization for Primary Key table schema changes and does not apply to MVs.
* Removed replicated_storage: This is a storage optimization for Primary Key tables and is not a valid property for MVs.
* Primary Key: MVs do not have a PRIMARY KEY clause. The data distribution and indexing are handled by the DISTRIBUTED BY and the internal sort keys.
References
* sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
* using_starrocks/async_mv/use_cases/create_partitioned_materialized_view.md
References
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.mdLý Thành
08/11/2026, 2:38 PMRocky
08/11/2026, 2:38 PMINSERT statement to run every 5 minutes in StarRocks, you can use the SUBMIT TASK command.
Syntax (StarRocks v3.3 and later)
Starting from version 3.3, StarRocks supports native scheduling directly within the SUBMIT TASK statement:
sql
SUBMIT TASK my_insert_task
SCHEDULE EVERY (INTERVAL 5 MINUTE)
AS
INSERT INTO target_table
SELECT * FROM source_table
-- Optional: WHERE condition to fetch only new data
WHERE created_at >= now() - INTERVAL 5 MINUTE;
Key Details
* Version Requirement: The SCHEDULE clause for periodic tasks requires StarRocks v3.3 or later.
* Task Name: my_insert_task is a unique identifier for your job.
* Interval: The minimum supported interval is 10 seconds.
* Asynchronous: Once submitted, the task runs in the background. You do not need to keep your SQL session open.
──────────
Monitoring and Management
1. Check Task Status
To see the definition and schedule of your created tasks:
sql
SELECT * FROM INFORMATION_SCHEMA.tasks WHERE task_name = 'my_insert_task';
2. Check Execution History
To see if specific runs succeeded or failed:
sql
SELECT * FROM INFORMATION_SCHEMA.task_runs
WHERE task_name = 'my_insert_task'
ORDER BY create_time DESC;
3. Delete a Task
If you want to stop the schedule:
sql
DROP TASK my_insert_task;
For StarRocks Versions Older than v3.3
If you are on an older version (v2.5 to v3.2), SUBMIT TASK only supports one-time execution. To achieve a 5-minute schedule on older versions, you must use an external orchestrator such as Apache Airflow, DolphinScheduler, or a simple Crontab script that triggers the SQL command.
References
• sql-reference/sql-statements/loading_unloading/pipe/CREATE_PIPE.md
• loading/InsertInto.md
• loading/RoutineLoad.md
• sql-reference/sql-statements/loading_unloading/routine_load/CREATE_ROUTINE_LOAD.mdLý Thành
08/12/2026, 1:34 AMRocky
08/12/2026, 1:35 AMkyber or `none`/`noop`.
* For SATA/HDD: Use mq-deadline.
2. FE Log Storage
Logs are stored in the directory defined by sys_log_dir (default: ${STARROCKS_HOME}/log).
* Medium: Standard HDD is usually sufficient. However, if your cluster handles extremely high query concurrency (resulting in massive audit and query logs), consider a dedicated disk or SSD to prevent logging I/O from impacting metadata operations.
* Retention Configuration:
* Default rotation is every 1024 MB or every day.
* Default retention is 7 days (sys_log_delete_age = 7d).
* Ensure the partition hosting the logs has enough head-room to prevent a full disk from crashing the FE process.
3. Summary Recommendation Table
Component | Recommended Disk Type | Capacity | File System
FE Metadata | SSD / NVMe | 100 GB+ | XFS
FE Logs | HDD or SSD | 50 GB - 200 GB* | XFS / ext4
_\_Capacity for logs depends on your configured retention period and audit log volume.*
Important Architecture Note
Because StarRocks uses a Follower/Leader mechanism (Raft-based), metadata is replicated across FE nodes. To ensure high availability, you should deploy at least three Follower FE nodes. This hardware-level redundancy is more critical for metadata safety than local RAID configurations, though RAID 1 or 10 is still a common best practice for local disk protection in production.
References
• deployment/plan_cluster.md
• deployment/environment_configurations.md
• administration/management/logs.md
• faq/operation_maintenance_faq.md
References
• faq/operation_maintenance_faq.md
• deployment/plan_cluster.md
• deployment/environment_configurations.md
• deployment/deployment_prerequisites.md
• introduction/Architecture.mdLý Thành
08/12/2026, 2:03 AMRocky
08/12/2026, 2:03 AMroot: The superuser role with global privileges across the entire cluster.
* db_admin: The built-in database administrator role. It specifically holds the CREATE DATABASE privilege at the Catalog level.
2. Required Privilege
If you are creating a custom role, you must grant it the CREATE DATABASE privilege on a specific catalog (e.g., the default default_catalog).
Example: Granting privilege to a custom role
sql
-- Create a custom role
CREATE ROLE developer_lead;
-- Grant the privilege to create databases in the default catalog
GRANT CREATE DATABASE ON CATALOG default_catalog TO ROLE developer_lead;
-- Assign the role to a user
GRANT developer_lead TO USER 'jack'@'%';
3. Summary of Roles
Role | Can Create Database? | Scope
root | Yes | Global (All Catalogs)
db_admin | Yes | All Catalogs
user_admin | No | Only manages users/roles
cluster_admin | No | Only manages nodes/infrastructure
public | No | Default role for all users (no privileges by default)
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
References
• administration/user_privs/authorization/User_privilege.md
• administration/user_privs/authorization/privilege_faq.md
• administration/user_privs/authorization/privilege_item.md
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/built_in_roles.md
• sql-reference/sql-statements/account-management/GRANT.mdLý Thành
08/12/2026, 2:04 AMdb_admin can do?Rocky
08/12/2026, 2:04 AMdb_admin role is a built-in role designed for users who need full control over data and database objects but do not need to manage the cluster infrastructure or user accounts.
1. Data and Object Management
A db_admin can perform almost all operations related to data and the objects that contain it:
* Catalogs & Databases: Create, drop, and alter catalogs (including external catalogs) and databases.
* Tables & Views: Create, drop, alter, and query (SELECT) tables and views. They can also perform DML operations like INSERT, UPDATE, and DELETE.
* Materialized Views: Create, drop, alter, and manually REFRESH materialized views.
* Loading: Create and manage PIPE objects for data loading.
2. System and Resource Management
Unlike a standard user, a db_admin has several system-level administrative privileges:
* Resources: Manage external resources (e.g., Spark, HDFS) and resource groups.
* Storage: Create and manage Storage Volumes and global functions.
* Advanced Features: Manage plugins, files, query blacklists, and security-related configurations (like masking or row-access policies).
3. What db_admin CANNOT do
To maintain security through separation of duties, the db_admin role is restricted from the following:
* User Management: It cannot create/drop users or grant/revoke privileges (this requires user_admin).
* Cluster Management: It cannot add, drop, or decommission FE/BE nodes (this requires cluster_admin).
* Role Mutation: db_admin is an immutable role; you cannot change its predefined set of permissions.
Privilege Summary Table
Level | Key Privileges
System | CREATE RESOURCE, CREATE EXTERNAL CATALOG, CREATE STORAGE VOLUME, PLUGIN, OPERATE
Catalog | CREATE DATABASE, USAGE, ALTER, DROP
Database | CREATE TABLE, CREATE VIEW, CREATE MATERIALIZED VIEW, CREATE PIPE
Table | SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, EXPORT
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
• administration/user_privs/authorization/privilege_item.mdLý Thành
08/12/2026, 2:06 AMdb_admin can select all db?Rocky
08/12/2026, 2:06 AMdb_admin role can SELECT from all databases and tables across all catalogs in the cluster.
As the built-in database administrator, db_admin is automatically granted full data-related privileges. This includes:
* All Catalogs: It has USAGE on all catalogs (internal and external).
* All Databases: It can create, drop, and alter any database.
* All Tables/Views: It has SELECT, INSERT, UPDATE, and DELETE privileges on all tables, views, and materialized views globally.
Key Points to Remember:
1. Immutable: You cannot revoke these privileges from the db_admin role; its scope is fixed by the system.
2. No Granting: While a db_admin can see and modify all data, they cannot grant these permissions to other users. Only the root or user_admin roles can manage privileges.
3. Visibility: Because db_admin has privileges on all databases, statements like SHOW DATABASES; or SHOW TABLES; will return every object in the cluster for a user with this role.
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
• administration/user_privs/authorization/privilege_faq.md
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/privilege_item.md
• item)
References
• administration/user_privs/authorization/built_in_roles.md
• administration/user_privs/authorization/user_privs.md
• administration/user_privs/authorization/User_privilege.md
• administration/user_privs/authorization/privilege_faq.md
• sql-reference/sql-statements/account-management/GRANT.mdLý Thành
08/12/2026, 2:35 AMRocky
08/12/2026, 2:35 AMdm_ds trên StarRocks và mức độ tiêu tốn tài nguyên hoàn toàn thực hiện được.
Dưới đây là các cách chính để bạn kiểm tra:
1. Kiểm tra các truy vấn đang chạy (Real-time)
Để xem các query đang thực thi của user dm_ds, bạn có thể sử dụng các lệnh sau:
* Xem trên FE hiện tại:
sql
SHOW PROC '/current_queries';
Cột User sẽ hiển thị tên người dùng, còn các cột MemoryUsage (Bộ nhớ) và CPUTime (Thời gian CPU) sẽ cho bạn biết mức độ "ngốn" tài nguyên của query đó.
* Xem trên toàn bộ cụm (Global - Version 3.4+):
sql
SHOW PROC '/global_current_queries';
* Sử dụng bảng hệ thống (Dễ lọc hơn):
Nếu phiên bản StarRocks của bạn hỗ trợ, bạn có thể dùng SQL để lọc trực tiếp:
sql
SELECT * FROM information_schema.active_queries WHERE user = 'dm_ds';
2. Kiểm tra các tác vụ Load dữ liệu (Load Jobs)
Nếu "job" bạn nói là các tác vụ nạp dữ liệu (như Broker Load, Insert Into), bạn có thể kiểm tra trong database cụ thể:
sql
USE <tên_database>;
SHOW LOAD WHERE Label LIKE '%'; -- Sau đó bạn tìm theo User/Label của dm_ds
Hoặc với Routine Load (nạp từ Kafka):
sql
SHOW ROUTINE LOAD FOR <tên_database>;
3. Kiểm tra các Task đã lập lịch (Scheduled Tasks)
Nếu user dm_ds sử dụng tính năng Task của StarRocks:
sql
-- Xem danh sách task
SHOW TASKS;
-- Xem lịch sử chạy và tài nguyên tiêu tốn của các lần chạy gần đây
SELECT * FROM information_schema.task_runs WHERE user = 'dm_ds' ORDER BY create_time DESC;
4. Kiểm tra qua Resource Group
Nếu bạn có phân quyền user dm_ds vào một Resource Group riêng, bạn có thể xem tổng tài nguyên mà group đó đang chiếm dụng:
sql
SHOW USAGE RESOURCE GROUPS;
Lệnh này sẽ hiển thị BEInUseCpuCores (CPU đang dùng) và BEInUseMemBytes (Bộ nhớ đang dùng) của từng group.
Tóm lại:
Cách nhanh nhất để "bắt" các query đang chạy tốn resource của user đó là:
1. Chạy SHOW PROC '/current_queries'.
2. Tìm dòng có User là dm_ds.
3. Nhìn vào cột MemoryUsage và CPUTime.
Nếu query đó gây treo hệ thống, bạn có thể lấy QueryId và dừng nó bằng lệnh: KILL QUERY 'query_id';
References
• using_starrocks/running_queries.md
• administration/management/resource_management/query_queues.md
• sql-reference/sql-statements/loading_unloading/SHOW_LOAD.md
• administration/management/resource_management/resource_group.md
References
• sql-reference/sql-statements/loading_unloading/SHOW_LOAD.mdLý Thành
08/12/2026, 7:59 AMRocky
08/12/2026, 7:59 AMnot all backends have path info repeats every second because the FE's Tablet Scheduler cannot see the disk storage information for one or more BE (Backend) nodes.
* Check BE Status: Run SHOW PROC '/backends'; in your SQL editor.
* What to look for: Check if any BE has Alive = false or if the Disk related columns are empty/zero.
* Solution: If a BE is down or has lost its storage path, restart that BE or fix its storage_root_path configuration. Once all BEs report their paths correctly, this log will stop.
2. Change FE Log Configuration
You can modify the following parameters in your fe/conf/fe.conf file to reduce log volume and save disk space. Note: Most of these require an FE restart to take effect.
A. Reduce Log Level (To hide INFO logs)
Change the log level from INFO to WARN. This will suppress the connection messages and "path info" messages, as they are INFO level.
properties
sys_log_level = WARN
B. Enable Log Compression
Enable Gzip compression for rotated log files to significantly reduce disk usage.
properties
sys_log_enable_compress = true
C. Adjust Retention and Rotation
If you want to keep fewer logs or rotate them faster, adjust these:
* sys_log_delete_age = 3d (Keep only 3 days instead of 7)
* sys_log_roll_num = 5 (Keep only 5 rotated files)
* log_roll_size_mb = 512 (Rotate the file when it reaches 512MB instead of 1GB)
3. Suppress Specific Modules (Advanced)
If you want to keep the overall level at INFO but silence only the noisy modules (like TabletScheduler or AutoStatistic), you can add them to the sys_log_warn_modules list in `fe.conf`:
properties
sys_log_warn_modules = com.starrocks.clone.TabletScheduler, com.starrocks.statistic.StatisticExecutor
4. Stop MySQL Connection Noise
The logs show Connection established from DBeaver every few seconds.
* This is often caused by a "Keep Alive" or "Auto-refresh" setting in your SQL client (DBeaver).
* Changing sys_log_level = WARN (Step 2A) is the most effective way to hide these from the FE log.
Summary Checklist
1. Run SHOW PROC '/backends'; to ensure all nodes are healthy.
2. Edit fe/conf/fe.conf.
3. Set sys_log_level = WARN.
4. Set sys_log_enable_compress = true.
5. Restart the FE node.
References
• administration/management/FE_configuration.md
• administration/management/logs.md
• faq/Deploy_faq.md
References
• administration/management/FE_configuration.mdLý Thành
08/12/2026, 9:23 AMRocky
08/12/2026, 9:23 AMON instead of IN, and explicitly specify if it is a USER or a ROLE.
The correct query is:
sql
GRANT CREATE TABLE ON DATABASE dmapp TO USER hungnm40;
Key details:
* Keyword: Use ON DATABASE (instead of IN DATABASE).
* User Identity: If the user hungnm40 was created with a specific host (e.g., 'hungnm40'@'%'), use the full identity: TO USER 'hungnm40'@'%'.
* Prerequisite: If you are using multiple catalogs, ensure you have the correct catalog selected (e.g., SET CATALOG default_catalog;) before running the grant.
* Catalog Usage: The user hungnm40 will also need the USAGE privilege on the catalog containing that database to actually access it.
sql
GRANT USAGE ON CATALOG default_catalog TO USER hungnm40;
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/privilege_item.md
• sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md
References
• sql-reference/sql-statements/account-management/GRANT.md
• sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md
• administration/user_privs/authorization/privilege_item.mdLý Thành
08/12/2026, 9:24 AMRocky
08/12/2026, 9:24 AMALTER (không phải ALTER TABLE khi đi kèm với ON DATABASE).
Tùy vào mục đích của bạn, có 2 cách viết đúng như sau:
1. Nếu bạn muốn cho phép user được sửa thông tin của chính Database (như đổi tên DB)
Sử dụng cú pháp `GRANT ALTER ON DATABASE`:
sql
GRANT ALTER ON DATABASE dmapp TO USER hungnm40;
2. Nếu bạn muốn cho phép user được sửa cấu trúc của TẤT CẢ các bảng trong Database đó (Phổ biến nhất)
Bạn cần sử dụng cú pháp `ON ALL TABLES IN DATABASE`:
sql
GRANT ALTER ON ALL TABLES IN DATABASE dmapp TO USER hungnm40;
Lưu ý quan trọng:
* User Identity: Đảm bảo user hungnm40 đã được tạo. Nếu user được tạo kèm host, hãy viết đầy đủ: TO USER 'hungnm40'@'%'.
* Catalog: Bạn cần thực hiện lệnh SET CATALOG default_catalog; (hoặc tên catalog tương ứng) trước khi chạy lệnh GRANT này.
* Quyền bổ sung: Để user có thể thao tác hoàn chỉnh, thường họ sẽ cần thêm quyền USAGE trên Catalog:
sql
GRANT USAGE ON CATALOG default_catalog TO USER hungnm40;
Tóm lại: Nếu mục đích của bạn là để user hungnm40 có thể chạy các lệnh như ALTER TABLE dmapp.my_table ..., hãy sử dụng Cách 2.
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/privilege_item.md
• sql-reference/sql-statements/account-management/SET_CATALOG.md
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/privilege_item.md
.).**
References
• sql-reference/sql-statements/account-management/GRANT.mdLý Thành
08/12/2026, 9:25 AMRocky
08/12/2026, 9:25 AMALTER privilege does not include the ability to DROP a table in StarRocks. They are distinct privileges.
• ALTER: Allows you to modify the table schema (add/drop columns), rename the table, or change properties.
• DROP: Allows you to delete the table entirely.
If you want a user to be able to do both, you must grant them both privileges or use `ALL`:
Granting both specifically
sql
GRANT ALTER, DROP ON ALL TABLES IN DATABASE dmapp TO USER hungnm40;
Granting all privileges (Select, Insert, Alter, Drop, etc.)
sql
GRANT ALL ON ALL TABLES IN DATABASE dmapp TO USER hungnm40;
Summary of Table Privileges
Privilege | Description
ALTER | Modifies table structure or refreshes metadata.
DROP | Deletes/Drops the table.
ALL | Includes ALTER, DROP, SELECT, INSERT, UPDATE, etc.
References
• administration/user_privs/authorization/privilege_item.md
• sql-reference/sql-statements/account-management/GRANT.md
References
• administration/user_privs/authorization/privilege_item.mdLý Thành
08/13/2026, 2:32 AMRocky
08/13/2026, 2:32 AMsql
INSERT OVERWRITE losrep.application
BY NAME
SELECT * FROM dmapp.losrep_application;
Các lưu ý quan trọng:
1. Phiên bản hỗ trợ: Tính năng BY NAME cho lệnh INSERT được chính thức hỗ trợ từ StarRocks v3.4. Nếu bạn dùng phiên bản cũ hơn (như 3.0, 3.1, 3.2), từ khóa này sẽ gây lỗi cú pháp.
2. Cơ chế hoạt động:
* Khớp theo tên: Hệ thống sẽ tự động đối chiếu tên cột trả về từ lệnh SELECT * với tên cột của bảng đích losrep.application, bất kể thứ tự các cột như thế nào.
* Cột thừa/thiếu: Các cột có trong SELECT nhưng không có trong bảng đích sẽ bị bỏ qua. Các cột có trong bảng đích nhưng không có trong SELECT sẽ được điền giá trị mặc định (DEFAULT hoặc NULL).
3. INSERT OVERWRITE: Lệnh này sẽ xóa toàn bộ dữ liệu cũ trong bảng đích (hoặc partition cụ thể nếu được chỉ định) và thay thế bằng dữ liệu mới từ câu lệnh truy vấn.
4. Tên bảng/DB: Nếu application hoặc losrep trùng với các từ khóa dự phòng của hệ thống, bạn nên bao chúng trong dấu backtick (ví dụ: `` losrep.application ``).
Nếu bạn dùng phiên bản thấp hơn 3.4:
Bạn phải bỏ BY NAME và đảm bảo thứ tự các cột trong câu lệnh SELECT khớp hoàn toàn với thứ tự cột trong bảng đích:
sql
-- Dành cho StarRocks < 3.4 (Khớp theo vị trí)
INSERT OVERWRITE losrep.application
SELECT * FROM dmapp.losrep_application;
References
• sql-reference/sql-statements/loading_unloading/INSERT.md
• loading/InsertInto.md
References
• loading/InsertInto.md
• sql-reference/sql-statements/loading_unloading/INSERT.mdLý Thành
08/13/2026, 2:43 AMRocky
08/13/2026, 2:43 AMUSER: Bạn cần thêm từ khóa USER trước tên người dùng.
2. Cấu trúc ON TABLE: Nếu bạn đã chỉ định tên bảng dưới dạng database.table (dwh.af_extract_mapping), bạn không cần thêm đoạn IN DATABASE dwh nữa.
3. Quyền UPDATE: Quyền này khả dụng cho các bảng thuộc loại Primary Key table.
Câu lệnh đúng:
sql
GRANT INSERT, UPDATE ON TABLE dwh.af_extract_mapping TO USER 'hoangqv'@'%';
Một số lưu ý:
* Database context: Đảm bảo bạn đã chọn đúng catalog (thường là default_catalog) bằng lệnh SET CATALOG default_catalog; trước khi thực hiện lệnh GRANT.
* User existence: Người dùng 'hoangqv'@'%' phải tồn tại trong hệ thống.
* Quyền USAGE: Để user có thể truy cập vào database và bảng, họ cần có quyền USAGE trên catalog và database đó:
sql
GRANT USAGE ON CATALOG default_catalog TO USER 'hoangqv'@'%';
GRANT USAGE ON DATABASE dwh TO USER 'hoangqv'@'%';
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/privilege_item.md
References
• sql-reference/sql-statements/account-management/GRANT.mdLý Thành
08/14/2026, 8:30 AMRocky
08/14/2026, 8:30 AMfe/conf/fe.conf. Ensure the priority_networks is set correctly to avoid the FE picking the wrong IP address (e.g., a Docker bridge IP).
properties
# Example fe.conf
priority_networks = 192.168.1.0/24
2. Register the New FEs (Run on the current Leader)
Connect to your existing FE using a MySQL client and run the following command for each new node:
sql
-- To add a Follower (contributes to HA/voting)
ALTER SYSTEM ADD FOLLOWER "IP_OF_NEW_FE:9010";
-- OR to add an Observer (read-only, does not contribute to HA quorum)
-- ALTER SYSTEM ADD OBSERVER "IP_OF_NEW_FE:9010";
_Note: 9010 is the default edit_log_port._
3. Start the New FE
On the new server, start the FE process by pointing it to the existing Leader to synchronize metadata:
bash
bin/start_fe.sh --helper EXISTING_FE_IP:9010 --daemon
Wait for the metadata to sync. After the first successful start, you no longer need the --helper flag.
4. Verify the Cluster Status
Back in the MySQL client, check the status:
sql
SHOW FRONTENDS\G
* Alive: Should be true.
* Role: Should show FOLLOWER.
* IsMaster: One will be true (the Leader), others false.
5. (Recommended) Load Balancing
Since you now have multiple FEs, you should use a Load Balancer (like HAProxy or nginx) or a VIP (Virtual IP) in front of them to distribute client connections and handle automatic failover if the Leader changes.
Important Notes:
* Odd Numbers: Always aim for an odd number of Followers (3, 5) to maximize fault tolerance.
* Metadata Backup: Ensure the meta/ directory has enough disk space.
* Clock Sync: Ensure all FE and BE nodes have synchronized clocks via NTP.
References
• deployment/deploy_starrocks.md
• administration/management/FE_Column.mdLý Thành
08/14/2026, 8:36 AMRocky
08/14/2026, 8:36 AMLý Thành
08/14/2026, 8:54 AMRocky
08/14/2026, 8:54 AMNew_IP_1 and New_IP_2).
2. In the MySQL client (connected to your Existing_FE_IP), run:
sql
ALTER SYSTEM ADD FOLLOWER "New_IP_1:9010";
ALTER SYSTEM ADD FOLLOWER "New_IP_2:9010";
3. Start the new FEs using the --helper flag:
bash
./bin/start_fe.sh --helper Existing_FE_IP:9010 --daemon
4. Verify all 3 are Alive and Follower using SHOW FRONTENDS;.
Step 2: Migrate the Leader
If your Existing_FE_IP is currently the Leader (Master), you need to move that role to one of the new nodes.
1. Stop the FE on the `Existing_FE_IP`:
bash
./bin/stop_fe.sh
2. The cluster will automatically elect one of the new nodes as the new Leader. Check this by connecting to one of the new IPs and running SHOW FRONTENDS;.
Step 3: Remove the Old FE from the Cluster
Now that the cluster is running on the two new nodes, remove the old IP from the StarRocks metadata:
sql
ALTER SYSTEM DROP FOLLOWER "Existing_FE_IP:9010";
Step 4: Set Up the Load Balancer on the Old IP
Now that the Existing_FE_IP is no longer used by StarRocks, you can repurpose it.
1. If the IP was a physical IP on a server: Install HAProxy on that server.
2. If using a VIP (Keepalived): Configure the VIP to be the Existing_FE_IP.
3. HAProxy Configuration: Configure HAProxy to listen on the query_port (default 9030) and route traffic to the new FE IPs.
Example HAProxy snippet:
haproxy
listen starrocks_cluster
bind Existing_FE_IP:9030
mode tcp
option tcplog
balance roundrobin
server fe1 New_IP_1:9030 check
server fe2 New_IP_2:9030 check
Why this is the best approach:
* Zero downtime for applications: Since the Load Balancer takes over the Existing_FE_IP, your apps never notice a change.
* Safety: You ensure the cluster has a healthy majority on new IPs before touching the original node.
* Metadata Integrity: StarRocks metadata is very sensitive to IP changes. Dropping the old node and adding new ones is much cleaner than trying to "rename" the IP of a running single-node cluster.
Important Note on priority_networks
Before starting the new FEs, ensure you set the priority_networks in their fe.conf to their respective new subnets. This prevents them from accidentally binding to the wrong network interface.
References
• administration/management/FE_Column.md
• deployment/deploy_starrocks.md
• administration/Meta_recovery.md
References
• administration/Meta_recovery.md
• deployment/upgrade.md
• deployment/deploy_manually.md
• administration/management/enable_fqdn.mdLý Thành
08/14/2026, 9:01 AMRocky
08/14/2026, 9:01 AMmeta/ directory, the FE will fail to start because of an "IP mismatch" error.
The correct workflow to re-add the old FE:
1. Stop and Drop (You've already planned this):
* Stop the old FE process.
* From the new Leader, run: ALTER SYSTEM DROP FOLLOWER "Old_IP:9010";
2. Change the Server IP:
* Change the IP address of the server to the new one (e.g., New_IP_3).
3. Clean the Metadata (Crucial):
* On that server, go to your StarRocks FE directory.
* Delete or rename the meta/ folder:
bash
mv fe/meta fe/meta_backup
_ _Note: Don't worry about data loss; this node will pull a fresh copy of the metadata from the current Leader when it joins.*
4. Update fe.conf:
* Ensure priority_networks in fe/conf/fe.conf is updated to reflect the new IP range/subnet.
5. Re-register the Node:
* Connect to your current Leader (one of the new FEs you set up) via MySQL and run:
sql
ALTER SYSTEM ADD FOLLOWER "New_IP_3:9010";
6. Start the FE as a "Helper":
* On the old server (now with the new IP), start the FE by pointing it to the current Leader:
bash
bin/start_fe.sh --helper NEW_LEADER_IP:9010 --daemon
Summary of why you must delete `meta/`:
StarRocks FEs use a library called BDBJE for metadata replication. BDBJE records the node's identity and IP address in its image files. If the IP changes, the library sees a conflict and refuses to start. Deleting the meta/ folder forces the node to start "clean" and download the current, correct metadata state from the cluster Leader.
Final Cluster State:
After this, you will have:
* 1 Load Balancer (running on the original Existing_FE_IP).
* 3 FE Followers (running on 3 new/updated IPs) behind that Load Balancer.
* Full High Availability.
References
• administration/Meta_recovery.md
• administration/management/FE_Column.md
• deployment/deploy_starrocks.md
References
• administration/Meta_recovery.md
• administration/management/enable_fqdn.md
• administration/stargo.md