Archive #
Syntax | Description | Type |
---|---|---|
SHOW ARCHIVE RULES [FROM schemaName] | View archive rule | 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 ? * *”))) )) | Create archive rule | 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 ? * *”))) )) | Modify archive rule | RDL |
DROP ARCHIVE RULE [IF EXISTS] ruleName | Delete archive rule | RDL |
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
Column | Description |
---|---|
table | Archive table name |
archive_column | Archive column |
archive_algorithm_type | Archive algorithm |
archive_algorithm_props | Archive algorithm properties |
storage_algorithm_type | Storage algorithm |
storage_algorithm_props | Storage algorithm properties |
scheduler_algorithm_type | Scheduler algorithm |
scheduler_algorithm_props | Scheduler 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 ;