Updating a View

Some views can be updated directly if they meet certain criteria (e.g., they reference a single table without aggregate functions).Syntax:

UPDATE view_name SET column1 = value1 WHERE condition;

Example:

UPDATE employee_view
SET salary = salary * 1.1
WHERE employee_id = 1;

Explanation: This updates the salary of the employee with employee_id 1, increasing it by 10%. The update reflects in the underlying employees table.


Comments

Leave a Reply

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