Purpose
This statement is used to modify the properties of a materialized view log (MLOG).
Privilege requirements
To execute the ALTER MATERIALIZED VIEW LOG statement, the current user must have the ALTER privilege on the base table. For more information about privileges in OceanBase Database, see Privilege classification in Oracle mode.
Syntax
ALTER MATERIALIZED VIEW LOG ON [schema.]table_name alter_mlog_action_list;
alter_mview_action_list:
alter_mlog_action [, alter_mlog_action ...]
alter_mlog_action:
parallel_clause
| PURGE [[START WITH expr] [NEXT expr]]
parallel_clause:
NOPARALLEL
| PARALLEL integer
Parameters
| Parameter | Description |
|---|---|
| schema. | Optional. Specifies the schema where the base table of the materialized view log is located. If you omit schema., the base table is assumed to be in the schema of the current session. |
| table_name | Specifies the name of the base table corresponding to the materialized view log. |
| alter_mlog_action_list | A list of operations that can be performed to modify the materialized view log. Multiple operations can be specified, separated by commas (,). For more information, see alter_mlog_action below. |
alter_mlog_action
parallel_clause: Used to modify the parallelism of the materialized view log table. Valid values:NOPARALLEL: Specifies a parallelism of 1, which is the default value.PARALLEL integer: Specifies the parallelism, whereintegeris an integer greater than or equal to 1.
Example:
ALTER MATERIALIZED VIEW LOG ON tbl1 PARALLEL 5;PURGE [[START WITH expr] [NEXT expr]]: Used to modify the time interval for the background cleanup task of the materialized view log.[START WITH expr]: Optional. Specifies the initial cleanup time for the materialized view log.[NEXT expr]: Optional. Specifies the next cleanup time for the materialized view log.
Notice
Make sure that the time expressions
START WITH exprandNEXT exprare set to future dates and times. Otherwise, an error will occur.It is recommended to use
current_dateto represent the current time in the current time zone. Here are some examples of time expressions:Clean up expired materialized view log records every 10 seconds starting from the current time (
current_date).START WITH current_date NEXT current_date + INTERVAL '10' SECONDClean up expired materialized view log records every 10 hours starting from the current time (
current_date).START WITH current_date NEXT current_date + INTERVAL '10' HOURClean up expired materialized view log records every 1 day starting from the current time (
current_date).START WITH current_date NEXT current_date + 1
Examples:
ALTER MATERIALIZED VIEW LOG ON tbl1 PURGE START WITH current_date;ALTER MATERIALIZED VIEW LOG ON tbl1 PURGE NEXT current_date + 1;ALTER MATERIALIZED VIEW LOG ON tbl1 PURGE START WITH current_date NEXT current_date + 1;
