Logo
Archive

Archive #

SyntaxDescriptionType
SHOW ARCHIVE RULES [FROM schemaName]View archive ruleRQL
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 ruleRDL
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 ? * *”))) ))Modify archive ruleRDL
DROP ARCHIVE RULE [IF EXISTS] ruleNameDelete archive ruleRDL

1. View Archive Rule #

SHOW ARCHIVE RULES [FROM schemaName] 

Example

View all archive rule

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 ? * * |
+--------------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+

View specified archive rule

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 ? * * |
+---------+----------------+-------------------------+-------------------------------------------------------------------------------+------------------------+-------------------------+--------------------------+---------------------------------------------------+

Output Description

ColumnDescription
tableArchive table name
archive_columnArchive column
archive_algorithm_typeArchive algorithm
archive_algorithm_propsArchive algorithm properties
storage_algorithm_typeStorage algorithm
storage_algorithm_propsStorage algorithm properties
scheduler_algorithm_typeScheduler algorithm
scheduler_algorithm_propsScheduler algorithm properties

2. Create Archive Rule #

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 ? * *"))) ))

Example

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 ? * *")))
);

Parameter Description

For related algorithms, please refer to built-in algorithm

3. Modify Archive Rule #

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 ? * *"))) ))

Example

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 ? * *")))
);

Parameter Description

For related algorithms, please refer to built-in algorithm

4. Delete Archive Rule #

DROP ARCHIVE RULE ruleName ;

Example

DROP ARCHIVE RULE  t_order ;