notebook/996/doirs/备份语句.sql
2025-07-11 15:32:31 +08:00

33 lines
1.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

show load warnings on 'http://10.0.8.10:8040/api/_load_error_log?file=__shard_8/error_log_insert_stmt_74aeb570d44748a-a0f64c2db75e399c_74aeb570d44748a_a0f64c2db75e399c'
SHOW PARTITIONS FROM ods_active_account;
CREATE TABLE `dwd_retention_act_m` (
`game_id` int NOT NULL,
`user_id` bigint NOT NULL,
`ds` date NULL,
`rd` int NULL
) ENGINE = OLAP
DUPLICATE KEY(`game_id`, `user_id`, `ds`, rd)
PARTITION BY RANGE(`ds`) (
-- 手动添加预建分区示例2025-02-01 至 2025-07-01
PARTITION p202502 VALUES LESS THAN ("2025-03-01"),
PARTITION p202503 VALUES LESS THAN ("2025-04-01"),
PARTITION p202504 VALUES LESS THAN ("2025-05-01"),
PARTITION p202505 VALUES LESS THAN ("2025-06-01"),
PARTITION p202506 VALUES LESS THAN ("2025-07-01")
)
DISTRIBUTED BY HASH(ds, `game_id`) BUCKETS 32
PROPERTIES (
"min_load_replica_num" = "1", -- 建议≥1避免写入失败
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "MONTH",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"dynamic_partition.start" = "-5", -- 关键修改创建过去5个月分区
"dynamic_partition.end" = "3", -- 保留未来3个月分区
"dynamic_partition.buckets" = "32",
"dynamic_partition.prefix" = "p", -- 建议用短前缀(如"p"
"dynamic_partition.history_partition_num" = "5", -- 保留历史分区数
"storage_medium" = "hdd"
);