Logo
归档

归档 #

语法描述类型
SHOW ARCHIVE RULES [FROM schemaName]查看归档规则RQL
CREATE ARCHIVE RULE ruleName ( ARCHIVE_STRATEGY(ARCHIVE_COLUMN=columnName, ARCHIVE_ALGORITHM(TYPE(NAME=“archiveAlgorithmName”, PROPERTIES(“interval-unit”=“MONTHS”, “interval-amount”=1, “retain-amount”=12, “pre-allocate-amount”=2)))), SCHEDULER_ALGORITHM(TYPE(NAME=“schedulerAlgorithmName”, PROPERTIES(“schedule-cron-expr”=“0 15 10 ? * *”))) ))创建归档规则RDL
ALTER ARCHIVE RULE ruleName ( ARCHIVE_STRATEGY(ARCHIVE_COLUMN=columnName, ARCHIVE_ALGORITHM(TYPE(NAME=“archiveAlgorithmName”, PROPERTIES(“interval-unit”=“MONTHS”, “interval-amount”=1, “retain-amount”=12, “pre-allocate-amount”=2)))), SCHEDULER_ALGORITHM(TYPE(NAME=“schedulerAlgorithmName”, PROPERTIES(“schedule-cron-expr”=“0 15 10 ? * *”))) ))修改归档规则RDL
DROP ARCHIVE RULE [IF EXISTS] ruleName删除归档规则RDL

1. 查看归档规则 #

SHOW ARCHIVE RULES [FROM schemaName] 

示例

查看所有的归档规则

SHOW ARCHIVE RULES;
SHOW ARCHIVE RULES FROM sharding_db;

+--------------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+
| table        | archive_column | archive_algorithm_type  | archive_algorithm_props                                                       | storage_algorithm_type | storage_algorithm_props | scheduler_algorithm_type | scheduler_algorithm_props                         |
+--------------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+
| t_order      | createtime     | SphereEx:TIME_PARTITION | interval-amount=1,pre-allocate-amount=2,interval-unit=MONTHS,retain-amount=12 |                        |                         | SphereEx:TIMED_TASK      | schedule-cron-expr=0 15 10 ? * *|
| t_order_item | createtime     | SphereEx:TIME_PARTITION | interval-amount=2,pre-allocate-amount=4,interval-unit=DAYS,retain-amount=13   |                        |                         | SphereEx:TIMED_TASK      | schedule-cron-expr=0 13 9 ? * * |
+--------------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+

查看指定归档规则

SHOW ARCHIVE TABLE RULE t_order;
SHOW ARCHIVE TABLE RULE t_order FROM sharding_db;

+---------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+
| table   | archive_column | archive_algorithm_type  | archive_algorithm_props                                                       | storage_algorithm_type | storage_algorithm_props | scheduler_algorithm_type | scheduler_algorithm_props                         |
+---------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+
| t_order | createtime     | SphereEx:TIME_PARTITION | interval-amount=1,pre-allocate-amount=2,interval-unit=MONTHS,retain-amount=12 |                        |                         | SphereEx:TIMED_TASK      | schedule-cron-expr=0 15 10 ? * * |
+---------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+

输出说明

说明
table归档的表名
archive_column归档字段
archive_algorithm_type归档算法
archive_algorithm_props归档算法参数
storage_algorithm_type存储算法
storage_algorithm_props存储算法参数
scheduler_algorithm_type调度算法
scheduler_algorithm_props调度算法参数

2. 创建归档规则 #

CREATE ARCHIVE RULE ruleName ( ARCHIVE_STRATEGY(ARCHIVE_COLUMN=columnName, ARCHIVE_ALGORITHM(TYPE(NAME="archiveAlgorithmName", PROPERTIES("interval-unit"="MONTHS", "interval-amount"=1, "retain-amount"=12, "pre-allocate-amount"=2)))), SCHEDULER_ALGORITHM(TYPE(NAME="schedulerAlgorithmName", PROPERTIES("schedule-cron-expr"="0 15 10 ? * *"))) ))

示例

CREATE ARCHIVE RULE t_order (
    ARCHIVE_STRATEGY(ARCHIVE_COLUMN=createtime, ARCHIVE_ALGORITHM(TYPE(NAME="SphereEx:TIME_PARTITION", PROPERTIES("interval-unit"="MONTHS", "interval-amount"=1, "retain-amount"=12, "pre-allocate-amount"=2)))),
    SCHEDULER_ALGORITHM(TYPE(NAME="SphereEx:TIMED_TASK", PROPERTIES("schedule-cron-expr"="0 15 10 ? * *")))
);

参数说明

相关算法请参考内置算法

3. 修改归档规则 #

ALTER ARCHIVE RULE ruleName ( ARCHIVE_STRATEGY(ARCHIVE_COLUMN=columnName, ARCHIVE_ALGORITHM(TYPE(NAME="archiveAlgorithmName", PROPERTIES("interval-unit"="MONTHS", "interval-amount"=1, "retain-amount"=12, "pre-allocate-amount"=2)))), SCHEDULER_ALGORITHM(TYPE(NAME="schedulerAlgorithmName", PROPERTIES("schedule-cron-expr"="0 15 10 ? * *"))) ))

示例

ALTER ARCHIVE RULE t_order (
    ARCHIVE_STRATEGY(ARCHIVE_COLUMN=createtime, ARCHIVE_ALGORITHM(TYPE(NAME="SphereEx:TIME_PARTITION", PROPERTIES("interval-unit"="MONTHS", "interval-amount"=1, "retain-amount"=12, "pre-allocate-amount"=2)))),
    SCHEDULER_ALGORITHM(TYPE(NAME="SphereEx:TIMED_TASK", PROPERTIES("schedule-cron-expr"="0 15 10 ? * *")))
);

参数说明

相关算法请参考内置算法

4. 删除归档规则 #

DROP ARCHIVE RULE ruleName ;

示例

DROP ARCHIVE RULE  t_order ;