Purpose
This statement is used to modify the attributes of a materialized view log (mlog).
Note
For OceanBase Database V4.3.5, the ALTER MATERIALIZED VIEW LOG statement is supported starting from V4.3.5 BP1.
Privileges
To execute the ALTER MATERIALIZED VIEW LOG statement, the current user must have the ALTER privilege on the base table (ordinary table or materialized view). For more information about OceanBase Database privileges, see Privilege types 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. The schema where the base table corresponding to the materialized view log file is located. If you omit schema., the default base table in the schema of the current session is used. |
| table_name | The name of the base table corresponding to the materialized view log file. |
| alter_mlog_action_list | The list of operations that can be performed on the materialized view log file. Multiple actions can be specified at once, separated by commas (,). For more information, see alter_mlog_action. |
alter_mlog_action
parallel_clause: specifies the degree of parallelism for the materialized view log table. Valid values:NOPARALLEL: the degree of parallelism is 1. This is the default value.PARALLEL integer: the specified degree of parallelism.integermust be an integer greater than or equal to 1.
Here is an example:
ALTER MATERIALIZED VIEW LOG ON tbl1 PARALLEL 5;PURGE [[START WITH expr] [NEXT expr]]: specifies the time interval for the background cleanup task of materialized view logs. Valid values:[START WITH expr]: optional. The time when the materialized view log file is cleared for the first time.[NEXT expr]: optional. The time when the materialized view log file is cleared the next time. If this parameter is specified, the value of this parameter must be later than the value of theSTART WITHparameter.
Notice
Make sure that the
START WITH exprandNEXT exprtime expressions are set to future time points. Otherwise, an error will occur.We recommend that you use
current_dateto specify the local time. 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 day starting from the current time (
current_date).START WITH current_date NEXT current_date + 1
Here is an example:
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;