You can read and update data by using views. Views that can be updated are called updatable views.
For example, you can execute the following DELETE statement to update the view named staff_dept_10:
DELETE staff_dept_10 WHERE employee_id = 200;
After receiving the request, an OceanBase database processes it in the following steps:
Parse the statement and replace
staff_dept_10with the view definition.Check whether the view to be updated meets the required constraints.
Try to merge the view into the main body of the query.
Generate and execute a new plan.
The following statement is executed in the OceanBase database:
DELETE employees WHERE employee_id = 200 and department_id = 10;
Take note of the following prerequisites for modifying a view by executing an UPDATE statement:
Each update operation modifies only one physical table.
Each row in the modified table appears only once in the query of the view. This does not apply to many-to-many join queries.
A modified view does not have the
WITH READ ONLYclause in its definition.