Using WITH READ ONLY

The WITH READ ONLY clause prevents any DML operations (INSERT, UPDATE, DELETE) on the view. This is useful for views intended solely for data retrieval.

Example

CREATE VIEW read_only_employees AS
SELECT employee_id, first_name, last_name
FROM employees
WITH READ ONLY;

Explanation: This view can be queried but cannot be modified. It provides a safeguard against accidental data changes, ensuring data integrity.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *